Share via


SecurityElement.Attributes 属性

定义

以名称/值对形式获取或设置 XML 元素特性。

public:
 property System::Collections::Hashtable ^ Attributes { System::Collections::Hashtable ^ get(); void set(System::Collections::Hashtable ^ value); };
public System.Collections.Hashtable Attributes { get; set; }
public System.Collections.Hashtable? Attributes { get; set; }
member this.Attributes : System.Collections.Hashtable with get, set
Public Property Attributes As Hashtable

属性值

XML 元素特性值的 Hashtable 对象。

例外

Hashtable 对象的名称或值无效。

该名称不是有效的 XML 特性名称。

示例

下面的代码演示如何使用 Attributes 属性获取 XML 元素的属性。 此代码示例是为 SecurityElement 类提供的一个更大示例的一部分。

Hashtable^ attributeKeys = xmlElement->Attributes;
String^ attributeValue = attributeKeys[ attributeName ]->ToString();
Hashtable attributeKeys = xmlElement.Attributes;
string attributeValue = attributeKeys[attributeName].ToString();
Dim attributeKeys As Hashtable = xmlElement.Attributes
Dim attributeValue As String = attributeKeys(attributeName).ToString()

注解

每个属性都以名称/值对的形式存储在 中 Hashtable

属性中的名称和值应仅包含有效的 XML 属性字符。 使用 Escape 从字符串中删除无效字符。

不支持带引号的字符串,因此名称/值对的字符串不应包含引号或其他需要引用的字符。

适用于