共用方式為


ConfigurationElement.GetAttributeValue(String) 方法

定義

傳回指定之屬性的值。

public:
 System::Object ^ GetAttributeValue(System::String ^ attributeName);
public object GetAttributeValue (string attributeName);
member this.GetAttributeValue : string -> obj
Public Function GetAttributeValue (attributeName As String) As Object

參數

attributeName
String

要求屬性的名稱。

傳回

物件,如果存在則表示要求的屬性;否則為 null

例外狀況

attributeName 參數是 null 或空白。

範例

下列範例會取得屬性值。

// Use any of the following lines to retrieve the attribute value.
// attributeBag[ConfigurationDemoGlobals.AttributeName] = "name";
attributeBag[ConfigurationDemoGlobals.AttributeName] =
    moduleproviderelement.GetAttributeValue("name");
// attributeBag[ConfigurationDemoGlobals.AttributeName] =
//    moduleproviderelement["name"];

備註

如果要求的屬性名稱不在 屬性的值 RawAttributes 中,這個方法會傳 null 回 。

您也可以使用 Item[] 屬性或 Microsoft.Web.Administration.ConfigurationAttribute.Value 屬性來取得屬性值。 GetAttributeValue 是慣用的方法。

適用於

另請參閱