UnscopedRefAttribute 類別

定義

用來表示 byref 逸出且未設定範圍。

public ref class UnscopedRefAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
public sealed class UnscopedRefAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)>]
type UnscopedRefAttribute = class
    inherit Attribute
Public NotInheritable Class UnscopedRefAttribute
Inherits Attribute
繼承
UnscopedRefAttribute
屬性

備註

有幾種情況下,C# 編譯器會將 a ref 視為隱含 scoped 處理——編譯器不允許 跳 ref 脫該方法。

例如:

  1. this 例如 struct 方法。
  2. 參考 ref 型別的 ref struct 參數。
  3. out 參數。

此屬性用於 ref 應允許 逃逸的情況。

以任何形式套用此屬性,都會影響適用 API 的使用者。 API 作者必須了解套用此屬性的終身影響,以及它可能如何影響使用者。

建構函式

名稱 Description
UnscopedRefAttribute()

初始化 UnscopedRefAttribute 類別的新執行個體。

屬性

名稱 Description
TypeId

在衍生類別中實作時,取得這個 Attribute的唯一標識碼。

(繼承來源 Attribute)

方法

名稱 Description
Equals(Object)

傳回值,這個值表示這個實例是否等於指定的物件。

(繼承來源 Attribute)
GetHashCode()

傳回這個實例的哈希碼。

(繼承來源 Attribute)
GetType()

取得目前實例的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,指出這個實例的值是否為衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於