AttributeTable.GetCustomAttributes 方法 (Type)

[本文档仅供预览,在以后的发行版中可能会发生更改。包含的空白主题用作占位符。]

返回提供给指定类型的所有特性的枚举。

命名空间:  Microsoft.Windows.Design.Metadata
程序集:  Microsoft.Windows.Design.Extensibility(在 Microsoft.Windows.Design.Extensibility.dll 中)

语法

声明
Public Function GetCustomAttributes ( _
    type As Type _
) As IEnumerable
public IEnumerable GetCustomAttributes(
    Type type
)
public:
IEnumerable^ GetCustomAttributes(
    Type^ type
)
member GetCustomAttributes : 
        type:Type -> IEnumerable 
public function GetCustomAttributes(
    type : Type
) : IEnumerable

参数

  • type
    类型:System.Type
    要为其获取类级别特性的类型。

返回值

类型:System.Collections.IEnumerable
特性的枚举。

异常

异常 条件
ArgumentNullException

type 为 nulla null reference (Nothing in Visual Basic)。

备注

此方法从不返回 nulla null reference (Nothing in Visual Basic) 枚举。

示例

下面的代码示例演示如何使用 GetCustomAttributes 方法来获取类型的自定义特性。 此代码示例摘自为 AttributeTable 类提供的一个更大的示例。

Dim attrs0 As IEnumerable = attributes.GetCustomAttributes(GetType(Button))
IEnumerable attrs0 = attributes.GetCustomAttributes(typeof(Button));

.NET Framework 安全性

请参见

参考

AttributeTable 类

GetCustomAttributes 重载

Microsoft.Windows.Design.Metadata 命名空间

AttributeTableBuilder