Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Reflection.Missing.Value做什么?_C#_System.reflection - Fatal编程技术网

C# System.Reflection.Missing.Value做什么?

C# System.Reflection.Missing.Value做什么?,c#,system.reflection,C#,System.reflection,我遇到了下面给出的代码 Object oMissing = System.Reflection.Missing.Value oDataDoc = wrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oM

我遇到了下面给出的代码

Object oMissing = System.Reflection.Missing.Value
oDataDoc = wrdApp.Documents.Open(ref oName, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                    ref oMissing);

我不明白你会怎么做。它会自动获取值或类似的值吗?

它表示
null
值。请注意,
null
不等于
Missing.Value

只是为了添加更多信息,正如您在下面的屏幕截图中所看到的,
Missing.Value
不等于
null
,实际上是
Missing
类对象的新实例


它表示
null

表示缺少的类的唯一实例


哇,见鬼,为什么这个值是通过引用传递的?@SargeBorsch谁知道呢?我猜这是一些
COM
的东西,而且
COM
的东西总是不太可读。是的,我完全同意你的看法。这篇Microsoft文章中的示例代码通过引用传递了
System.Reflection.Missing.Value
值:那么什么等于Missing.Value如果传递这个值,然后,单词API将认为没有为相应的参数提供值。在VB.NET中,您可以避免发送您不感兴趣的值;但早期的C#不支持默认参数。因此,作为替代,缺少。正在使用值。与null不同,Missing.Value允许API获取该参数的默认值(在其类中定义)并继续处理。为什么我们不能传递null而不是使用Missing.Value?我不理解背后的逻辑it@MurtazaMunshi我猜如果值为空,该行为可能不同于
缺少的.Value
。如果将该值传递为null,则不会为参数提供任何值。也请查看此论坛:-