22

I encountered a code given below

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);

I dont understand what will ref oMissing do. Will it automatically get the values or something like that?

halfer
  • 19,824
  • 17
  • 99
  • 186
Murtaza Munshi
  • 1,065
  • 4
  • 13
  • 40

2 Answers2

12

It represents null value. Note that null is not equal to Missing.Value

Just to add more information, as you can see in the screen shot below, Missing.Value is NOT equal to null, and in fact is a new instance of Missing class object

enter image description here

Prash
  • 1,122
  • 1
  • 8
  • 10
  • 1
    then what is equal to Missing.Value – Murtaza Munshi Sep 01 '13 at 06:54
  • 8
    If you pass this value, then the Word API would treat that no value is supplied for the respective parameter. In VB.NET you could avoid sending values that you are not interested in; but earlier C# doesn't used to support default parameters. Hence as an alternative _Missing.Value_ is being used. Unlike null, Missing.Value allows the API to take the default value of that parameter (as defined in it's class) and continue processing. – Prash Sep 01 '13 at 06:58
3

It represents the null value.

From MSDN

Represents the sole instance of the Missing class.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331