共用方式為


DebuggerDisplayAttribute.Name 屬性

定義

取得或設定顯示於偵錯工具變數視窗中的名稱。

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
public string? Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

屬性值

要顯示在偵錯工具變數視窗中的名稱。

範例

下列程式代碼範例會使調試程式變數視窗中顯示每個索引鍵的名稱和值。 未套用屬性時,索引和實值類型會顯示 (例如:“[0] {KeyValuePairs}”) 。 套用屬性時,索引鍵的名稱及其值會顯示 (例如,如果第一個索引鍵是 “one”,而其值為 1,則顯示方式為:“一 1”) 。 此程式代碼範例是提供給 類別之較大範例的 DebuggerDisplayAttribute 一部分。

[DebuggerDisplay("{value}", Name = "{key}")]
ref class KeyValuePairs
{
private:
    IDictionary^ dictionary;
    Object^ key;
    Object^ value;

public:
    KeyValuePairs(IDictionary^ dictionary, Object^ key, Object^ value)
    {
        this->value = value;
        this->key = key;
        this->dictionary = dictionary;
    }
};
[DebuggerDisplay("{value}", Name = "{key}")]
internal class KeyValuePairs
{
    private IDictionary dictionary;
    private object key;
    private object value;

    public KeyValuePairs(IDictionary dictionary, object key, object value)
    {
        this.value = value;
        this.key = key;
        this.dictionary = dictionary;
    }
}
<DebuggerDisplay("{value}", Name := "{key}")>  _
Friend Class KeyValuePairs
    Private dictionary As IDictionary
    Private key As Object
    Private value As Object
    
    
    Public Sub New(ByVal dictionary As IDictionary, ByVal key As Object, ByVal value As Object) 
        Me.value = value
        Me.key = key
        Me.dictionary = dictionary

    End Sub
End Class

備註

值可以包含大括弧 ({ 和 }) 。 一對大括號內的文字會評估為字段、屬性或方法的名稱。

適用於