Type::Missing Field
Represents a missing value in the Type information. This field is read-only.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Use the Missing field for invocation through reflection to obtain the default value of a parameter. If the Missing field is passed in for a parameter value and there is no default value for that parameter, an ArgumentException is thrown.
Platform Notes
Silverlight for Windows Phone
The following code example shows the use of the Missing field to invoke a method with its default arguments.
There is no C# example, because C# cannot declare optional parameters.
Note: |
|---|
To run this example, see Building Examples That Use a Demo Method and a TextBlock Control. |
Option Strict Off Imports System.Reflection Public Class OptionalArg Public Function MyMethod(ByVal a As Integer, _ Optional ByVal b As Double = 1.2, Optional ByVal c As Integer = 1) As String Return "a = " & a & " b = " & b & " c = " & c End Function End Class Public Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) Dim o As New OptionalArg() Dim binding As BindingFlags = BindingFlags.Public Or BindingFlags.Instance Or _ BindingFlags.InvokeMethod Or BindingFlags.OptionalParamBinding Dim t As Type = GetType(OptionalArg) Dim param As Object() = {10, 20, 30} Dim result As Object = _ t.InvokeMember("MyMethod", binding, Nothing, o, New Object() {10, 55.3, 12}) outputBlock.Text &= result & vbLf result = _ t.InvokeMember("MyMethod", binding, Nothing, o, New Object() {10, 55.3, Type.Missing}) outputBlock.Text &= result & vbLf result = _ t.InvokeMember("MyMethod", binding, Nothing, o, New Object() {10, Type.Missing, Type.Missing}) outputBlock.Text &= result & vbLf End Sub End Class ' This example produces the following output: ' 'a = 10 b = 55.3 c = 12 'a = 10 b = 55.3 c = 1 'a = 10 b = 1.2 c = 1
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Note: