Missing 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示缺少的 Object。 此类不能被继承。
public ref class Missing sealed
public ref class Missing sealed : System::Runtime::Serialization::ISerializable
public sealed class Missing
public sealed class Missing : System.Runtime.Serialization.ISerializable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class Missing : System.Runtime.Serialization.ISerializable
type Missing = class
type Missing = class
interface ISerializable
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type Missing = class
interface ISerializable
Public NotInheritable Class Missing
Public NotInheritable Class Missing
Implements ISerializable
- 继承
-
Missing
- 属性
- 实现
以下示例演示如何使用 Missing 对象通过反射调用具有默认参数的方法。
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
Imports System.Reflection
<Assembly:CLSCompliant(True)>
Public Class MissingClass
Public Shared Sub MethodWithDefault(Optional value As Integer = 33)
Console.WriteLine("value = {0}", value)
End Sub
End Class
Public Module Example
Public Sub Main()
' Invoke without reflection.
MissingClass.MethodWithDefault()
' Invoke by using reflection.
Dim t As Type = GetType(MissingClass)
Dim mi As MethodInfo = t.GetMethod("MethodWithDefault")
mi.Invoke(Nothing, { Missing.Value })
End Sub
End Module
' The example displays the following output:
' value = 33
' value = 33
类 Missing 用于调用具有默认参数的方法,通常在使用反射时。
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
ISerializable. |
使用重新创建 SerializationInfo 对象的唯一实例所需的逻辑上下文信息设置 Missing 对象。 |
产品 | 版本 |
---|---|
.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, 10 |
.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 |