Missing Missing Missing Missing Class

Definition

Represents a missing Object. This class cannot be inherited.

public ref class Missing sealed : System::Runtime::Serialization::ISerializable
[System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public sealed class Missing : System.Runtime.Serialization.ISerializable
type Missing = class
    interface ISerializable
Public NotInheritable Class Missing
Implements ISerializable
Inheritance
MissingMissingMissingMissing
Attributes
ComVisibleAttribute SerializableAttribute
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 Value Value Value

Represents the sole instance of the Missing class.

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

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

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See Also