CodeClass2.Name 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置或获取类的名称。
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
属性值
表示类的名称的字符串。
实现
- 属性
示例
[C#]
public void CodeClass2MembersNameExample(DTE2 dte2)
{
// Before running this example, open a code document from a project
// and place the insertion point within a class definition.
try
{ // Get the CodeClass2 at the insertion point.
TextSelection sel =
TextSelection)dte2.ActiveDocument.Selection;
CodeClass2 cls = (CodeClass2)sel.ActivePoint.get_CodeElement(
vsCMElement.vsCMElementClass);
StringBuilder sb = new StringBuilder(cls.Name + " has the
following members:\n");
foreach (CodeElement ce in cls.Members)
{
sb.AppendLine(ce.Name);
}
// Display the name and members elements of the CodeClass.
MessageBox.Show(sb.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
注解
备注
在进行了某些类型的编辑之后,代码模型元素(例如类、结构、函数、特性、委托等)的值可能变为非确定性的,这意味着不能确定它们的值始终保持不变。 有关详细信息,请参阅 "代码模型元素值在 使用代码模型查找代码时 可能发生变化" (Visual Basic) "。