Missing Class

 

Represents a missing Object. This class cannot be inherited.

Namespace:   System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

System.Object
  System.Reflection.Missing

[SerializableAttribute]
[ComVisibleAttribute(true)]
public sealed class Missing : ISerializable

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticValue

Represents the sole instance of the Missing class.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISerializable.GetObjectData(SerializationInfo, StreamingContext)

Sets a SerializationInfo object with the logical context information needed to recreate the sole instance of the Missing object.

The Missing class is used to invoke a method with a default argument, typically when using reflection.

Only one instance of Missing, which is returned by the Value field, ever exists.

The following example shows how to use the Missing object to invoke a method with a default argument by using reflection.

using System;
using System.Reflection;

[assembly:CLSCompliant(true)]

public class MissingClass
{
   public static void MethodWithDefault(int value = 33)
   {
      Console.WriteLine("value = {0}", value);
   } 
}

public class Example
{
   public static void Main()
   {
      // Invoke without reflection
      MissingClass.MethodWithDefault();

      // Invoke by using reflection.
      Type t = typeof(MissingClass);
      MethodInfo mi = t.GetMethod("MethodWithDefault");
      mi.Invoke(null, new object[] { Missing.Value });
   }
}
// The example displays the following output:
//       value = 33  
//       value = 33  

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: