使用'Microsoft.Office.Interop.Word._Document.Close'时警告CS0467

2 c# compiler-warnings

问题(C#编译器警告消息):

警告CS0467:方法'Microsoft.Office.Interop.Word._Document.close(ref object,ref object,ref object)'和非方法'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close'之间的歧义.使用方法组.

(部分..)解决方案: 使用'Microsoft.Office.Interop.Word._Document.Close'时编译时间警告

困境:如果我明确表示Microsoft.Office.Interop.Word._Document,ReSharper警告我"类型转换是多余的"

问题:这个警告信息是否有真正的解决方案,而不仅仅是拼凑?

Han*_*ant 8

只是不要强制转换,C#不需要它:

Word._Application app = new Word.Application();
Word._Document doc = app.Documents.Add(...);
doc.Close(...);    // No ambiguity
app.Quit(...);
Run Code Online (Sandbox Code Playgroud)