Edit

Share via


Missing Class

Definition

Represents a missing Object. This class cannot be inherited.

C#
public sealed class Missing
C#
public sealed class Missing : System.Runtime.Serialization.ISerializable
C#
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class Missing : System.Runtime.Serialization.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.

C#
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

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

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

See also