You may receive a CS0117 compiler error when you explicitly implement an interface event (821175)
The information in this article applies to:
- Microsoft Visual C# .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# 2005, Express Edition
SYMPTOMS You can implement interface events in a class explicitly.
However, when you implement interface events explicitly, and you instantiate the class instance, you may receive
the following compiler error message: error CS0117: 'namespace. class name' does not
contain a definition for Interface name' CAUSEWhen a class explicitly implements events of an interface,
explicitly implemented events are not accessible from class instances.WORKAROUNDTo work around this problem, create an instance of the
interface, and then access the events. Use the following code to create an
instance of the interface to access events:
IMyInterface eventSample = new ExplicitEventSample();
eventSample.MyEvent += new MyDelegate(FindLength);
STATUS This
behavior is by design.REFERENCESFor more information about explicit interface
implementation, see the following Microsoft Developer Network
(MSDN) Web site:
Modification Type: | Minor | Last Reviewed: | 1/13/2006 |
---|
Keywords: | kbProgramming kbCompiler kbprb KB821175 kbAudDeveloper |
---|
|