SecurityElement.IsValidAttributeName(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷字串是否為有效的屬性名稱。
public:
static bool IsValidAttributeName(System::String ^ name);
public static bool IsValidAttributeName (string? name);
public static bool IsValidAttributeName (string name);
static member IsValidAttributeName : string -> bool
Public Shared Function IsValidAttributeName (name As String) As Boolean
參數
- name
- String
要測試有效性的屬性名稱。
傳回
如果 name
參數是有效的 XML 屬性名稱,則為 true
,否則為 false
。
範例
下列程式碼顯示 IsValidAttributeName 如何使用方法來判斷字串是否為有效的屬性名稱。 這個程式碼範例是針對類別提供之較大範例的一部分 SecurityElement 。
if ( SecurityElement::IsValidAttributeName( attributeName ) &&
SecurityElement::IsValidAttributeValue( attributeValue ) )
if (SecurityElement.IsValidAttributeName(attributeName) &&
SecurityElement.IsValidAttributeValue(attributeValue))
If SecurityElement.IsValidAttributeName(attributeName) AndAlso SecurityElement.IsValidAttributeValue(attributeValue) Then
備註
這個方法可以用來測試屬性,然後再將它加入至安全性元素。