.NET(C#)操作Office的Word时编译出现警告:方法和非方法之间存在二义性
使用C#来开发Office方面的东西,在操作Word时发现一处“二义性”的警告:
分析了一下,原因比较简单,先看下图:
Application继承了两个接口,两个接口中都有一个名为“Quit”的成员:
Application继承了两个接口,两个接口中都有一个名为“Quit”的成员:
1、_Application中的Quit方法:void Quit(ref object SaveChanges, ref object OriginalFormat, ref object RouteDocument);
2、ApplicationEvents4中的Quit事件:event ApplicationEvents4_QuitEventHandler Quit;
new Application() 返回的是类 ApplicationClass 的实例,ApplicationClass实现了以上接口: