閱讀英文版本

分享方式:


Missing 類別

定義

表示遺漏的 Object。 此類別無法獲得繼承。

C#
public sealed class Missing
C#
public sealed class Missing : System.Runtime.Serialization.ISerializable
C#
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class Missing : System.Runtime.Serialization.ISerializable
繼承
Missing
屬性
實作

範例

下列範例示範如何使用 對象來叫用 Missing 具有預設自變數的方法,方法是使用反映。

C#
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

備註

類別 Missing 是用來叫用具有預設自變數的方法,通常是在使用反映時。

欄位傳回Value的實例Missing只有一個 存在。

欄位

Value

表示 Missing 類別的唯一執行個體。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

設定 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

另請參閱