ConfigurationElement.GetAttributeValue(String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回指定特性的值。
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 是首选方法。