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 從字串中移除不正確字元。

不支援引號字串,因此名稱/值組的字串不應包含引號或其他需要引號的字元。

適用於