Missing Class
Represents a missing Object. This class cannot be inherited.
Assembly: mscorlib (in mscorlib.dll)
The Missing type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | GetHashCode | Serves as a hash function for a particular type. (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.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ISerializable::GetObjectData | Sets a SerializationInfo object with the logical context information needed to recreate the sole instance of the Missing object. |
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++).
Note |
|---|
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 Common Language Specification. Therefore, code that uses optional parameters is not CLS-compliant. For more information, see 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.
#using "target.dll" using namespace System; using namespace System::Reflection; void main() { // To invoke MyMethod with the default argument value, pass // Missing::Value for the optional parameter. MethodInfo^ mi = MissingSample::typeid->GetMethod("MyMethod"); mi->Invoke(nullptr, gcnew array<Object^> { Missing::Value }); }; /* This code example produces the following output: k = 33 */
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
