Missing Class

Definition

Represents a missing Object. This class cannot be inherited.

public ref class Missing sealed
public ref class Missing sealed : System::Runtime::Serialization::ISerializable
public sealed class Missing
public sealed class Missing : System.Runtime.Serialization.ISerializable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class Missing : System.Runtime.Serialization.ISerializable
type Missing = class
type Missing = class
    interface ISerializable
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type Missing = class
    interface ISerializable
Public NotInheritable Class Missing
Public NotInheritable Class Missing
Implements ISerializable
Inheritance
Missing
Attributes
Implements

Examples

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
Imports System.Reflection

<Assembly:CLSCompliant(True)>

Public Class MissingClass
   Public Shared Sub MethodWithDefault(Optional value As Integer = 33)
      Console.WriteLine("value = {0}", value)
   End Sub 
End Class   

Public Module Example
   Public Sub Main()
      ' Invoke without reflection.
      MissingClass.MethodWithDefault()
      
      ' Invoke by using reflection.
      Dim t As Type = GetType(MissingClass)
      Dim mi As MethodInfo = t.GetMethod("MethodWithDefault")
      mi.Invoke(Nothing, { Missing.Value })
   End Sub
End Module
' The example displays the following output:
'       value = 33 
'       value = 33

Remarks

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.

Fields

Value

Represents the sole instance of the Missing class.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

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

Applies to

See also