Recently, I am working on Office development. When operating Word, I found a warning of "ambiguity:
The reason is simple. Let's take a look at it first:
Application inherits two interfaces, both of which have a member named "Quit:
- _ Quit method in Application: void Quit (ref object SaveChanges, ref object OriginalFormat, ref object RouteDocument );
- Quit event in ApplicationEvents4: event ApplicationEvents4_QuitEventHandler Quit;
New Application () returns an instance of the ApplicationClass class. ApplicationClass implements the above interface:
ApplicationEvents4.Quit event is implemented in a strange way (row 258). Its name is changed to ApplicationEvents4_Event. Probably because the ApplicationClass class already has a method named Quit (slice 953 rows), there is a name conflict, so avoid it (but do not know why this method is used ). Because the DocumentBeforeClose event does not have a duplicate Member, its name is consistent with that defined in the interface.
Despite such processing, ApplicationEvents4_Event.Quit is not an explicit interface implementation, so two members with the same name appear: One method and one event (not a method ). At compilation, you must determine a method. The method may have a higher priority than the event, so the compiler "will use the method group ".
The above is my bold speculation. I don't know if it is reasonable. Please give me some advice.
Note: After you press F6 to compile, this warning will disappear, and the project will appear again after being regenerated.
As mentioned above, members of the same name are not allowed in c # (except for method overloading). For example, the following code cannot be compiled:
In this case, the implementation interface must be displayed.