CodeAttributeArgument.Name 属性

定义

获取或设置表示对象名称的字符串。

public:
 property System::String ^ default { System::String ^ get(); void set(System::String ^ value); };
public:
 property Platform::String ^ default { Platform::String ^ get(); void set(Platform::String ^ value); };
[System.Runtime.InteropServices.DispId(0)]
public string this { [System.Runtime.InteropServices.DispId(0)] get; [System.Runtime.InteropServices.DispId(0)] set; }
[<System.Runtime.InteropServices.DispId(0)>]
[<get: System.Runtime.InteropServices.DispId(0)>]
[<set: System.Runtime.InteropServices.DispId(0)>]
member this.Name : string with get, set
Default Public Property Name As String

属性值

String

表示的名称的字符串 CodeAttributeArgument

属性

示例

' Macro code.  
Sub codeArgNameExample()  
    Dim sel As TextSelection = _  
    CType(DTE.ActiveDocument.Selection, TextSelection)  
    Dim cls As CodeClass2 = CType(sel.ActivePoint. _  
    CodeElement(vsCMElement.vsCMElementClass), CodeClass2)  
    Dim attr As CodeAttribute2  
    Dim attrArg As CodeAttributeArgument  
    Dim msg As String  

    ' Loop through all of the attributes in the class.  
    For Each attr In cls.Attributes  
        ' Loop through all of the arguments for the attribute.  
        For Each attrArg In attr.Arguments  
            msg += attrArg.Value & " " & vbCr  
            ' If the argument has a name, list it.  
            If attrArg.Name <> Nothing Then  
                msg += "Name: " & attrArg.Name  
            End If  
        Next  
    Next  
    ' List the arguments for the attribute.  
    MsgBox("Attribute parameters for " & attr.Name _  
    & ": " & msg)  
End Sub  

注解

备注

在进行了某些类型的编辑之后,代码模型元素(例如类、结构、函数、特性、委托等)的值可能变为非确定性的,这意味着不能确定它们的值始终保持不变。 有关详细信息,请参阅 "代码模型元素值在 使用代码模型查找代码时 可能发生变化" (Visual Basic) "。

适用于