Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Missing Class

Represents a missing Object. This class cannot be inherited.

System.Object
  System.Reflection.Missing

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
[<Sealed>]
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type Missing =  
    class 
        interface ISerializable 
    end

The Missing type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public fieldStatic memberSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsValueRepresents 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 <PAVE OVER> Writing CLS-Compliant Code.

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.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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