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,则显示为:“one 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

注解

该值可以包含大括号 ({ 和 }) 。 将一对大括号内的文本计算为字段、属性或方法的名称。

适用于