Missing Class

Represents a missing Object. This class cannot be inherited.

System.Object
  System.Reflection.Missing

Namespace:  System.Reflection
Assemblies:   System.Runtime.InteropServices (in System.Runtime.InteropServices.dll)
  mscorlib (in mscorlib.dll)

[<Sealed>]
type Missing =  class end

The Missing type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public fieldStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryValueRepresents the sole instance of the Missing class.
Top

  NameDescription
Explicit interface implemetationPrivate methodISerializable.GetObjectDataSets a SerializationInfo object with the logical context information needed to recreate the sole instance of the Missing object.
Top

Missing is used to invoke a method with a default argument.

Only one instance of Missing ever exists.

The following example shows how to use Missing to invoke a method with a default argument. To compile and run this code example, you must first compile the following Visual Basic code as a DLL assembly named Target.dll. Save the code as Target.vb. From the command line, use vbc /t:library Target.vb to compile the assembly.

Imports System

Public Class MissingSample
    
    Public Shared Sub MyMethod(Optional k As Integer = 33)
        Console.WriteLine("k = " & k.ToString())
    End Sub

End Class

If you compile Target.dll in Visual Studio, by default the project name is used as the name of a namespace that contains the MissingSample class. Either remove the namespace from the Target project, or add a using Target; statement to the C# code (Imports Target in Visual Basic, using namespace Target; in Visual C++).

NoteNote

Visual Basic code is used for Target.dll because C# and Visual C++ do not support optional parameters in managed code. Optional parameters are not part of the Language Independence and Language-Independent Components. Therefore, code that uses optional parameters is not CLS-compliant. For more information, see Language Independence and Language-Independent Components.

When you compile the Visual Basic and C# versions of this code example, add references to Target.dll. For example, if you are compiling from the command line, use the /r:Target.dll option. The Visual C++ version of the code example already includes a #using statement for Target.dll.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft