CustomAttributeExtensions.GetCustomAttributes 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取套用至指定項目的自訂屬性集合。
擷取指定型別的自訂屬性集合,此集合套用至指定參數,並且可選擇性檢查該參數的祖系。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, Type ^ attributeType, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);
static member GetCustomAttributes : System.Reflection.ParameterInfo * Type * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo, attributeType As Type, inherit As Boolean) As IEnumerable(Of Attribute)
參數
- element
- ParameterInfo
要檢查的參數。
- attributeType
- Type
要搜尋的屬性類型。
- inherit
- Boolean
true
表示檢查element
的祖系,否則為false
。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 attributeType
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, Type ^ attributeType, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.MemberInfo element, Type attributeType, bool inherit);
static member GetCustomAttributes : System.Reflection.MemberInfo * Type * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo, attributeType As Type, inherit As Boolean) As IEnumerable(Of Attribute)
參數
- element
- MemberInfo
要檢查的成員。
- attributeType
- Type
要搜尋的屬性類型。
- inherit
- Boolean
true
表示檢查element
的祖系,否則為false
。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 attributeType
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定參數。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.ParameterInfo element, Type attributeType);
static member GetCustomAttributes : System.Reflection.ParameterInfo * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo, attributeType As Type) As IEnumerable(Of Attribute)
參數
- element
- ParameterInfo
要檢查的參數。
- attributeType
- Type
要搜尋的屬性類型。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 attributeType
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取自訂屬性集合,此集合套用至指定參數,並且可選擇性檢查該參數的祖系。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.ParameterInfo element, bool inherit);
static member GetCustomAttributes : System.Reflection.ParameterInfo * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo, inherit As Boolean) As IEnumerable(Of Attribute)
參數
- element
- ParameterInfo
要檢查的參數。
- inherit
- Boolean
true
表示檢查element
的祖系,否則為false
。
傳回
自訂屬性的集合,這些屬性已套用至 element
,如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定模組。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Module ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.Module element, Type attributeType);
static member GetCustomAttributes : System.Reflection.Module * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Module, attributeType As Type) As IEnumerable(Of Attribute)
參數
- element
- Module
要檢查的模型。
- attributeType
- Type
要搜尋的屬性類型。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 attributeType
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定成員。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.MemberInfo element, Type attributeType);
static member GetCustomAttributes : System.Reflection.MemberInfo * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo, attributeType As Type) As IEnumerable(Of Attribute)
參數
- element
- MemberInfo
要檢查的成員。
- attributeType
- Type
要搜尋的屬性類型。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 attributeType
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.MemberInfo element, bool inherit);
static member GetCustomAttributes : System.Reflection.MemberInfo * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo, inherit As Boolean) As IEnumerable(Of Attribute)
參數
- element
- MemberInfo
要檢查的成員。
- inherit
- Boolean
true
表示檢查element
的祖系,否則為false
。
傳回
自訂屬性的集合,這些屬性已套用至符合指定之準則的 element
,如果沒有這樣的屬性則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定組件。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Assembly ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.Assembly element, Type attributeType);
static member GetCustomAttributes : System.Reflection.Assembly * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Assembly, attributeType As Type) As IEnumerable(Of Attribute)
參數
- element
- Assembly
要檢查的組件。
- attributeType
- Type
要搜尋的屬性類型。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 attributeType
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取套用至指定參數的自訂屬性集合。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.ParameterInfo element);
static member GetCustomAttributes : System.Reflection.ParameterInfo -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo) As IEnumerable(Of Attribute)
參數
- element
- ParameterInfo
要檢查的參數。
傳回
自訂屬性的集合,這些屬性已套用至 element
,如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取套用至指定模組的自訂屬性集合。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Module ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.Module element);
static member GetCustomAttributes : System.Reflection.Module -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Module) As IEnumerable(Of Attribute)
參數
- element
- Module
要檢查的模型。
傳回
自訂屬性的集合,這些屬性已套用至 element
,如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取套用至指定成員的自訂屬性集合。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.MemberInfo element);
static member GetCustomAttributes : System.Reflection.MemberInfo -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo) As IEnumerable(Of Attribute)
參數
- element
- MemberInfo
要檢查的成員。
傳回
自訂屬性的集合,這些屬性已套用至 element
,如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取套用至指定組件的自訂屬性集合。
public:
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Assembly ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes (this System.Reflection.Assembly element);
static member GetCustomAttributes : System.Reflection.Assembly -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Assembly) As IEnumerable(Of Attribute)
參數
- element
- Assembly
要檢查的組件。
傳回
自訂屬性的集合,這些屬性已套用至 element
,如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定參數,並且可選擇性檢查該參數的祖系。
public:
generic <typename T>
where T : Attribute[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T> (this System.Reflection.ParameterInfo element, bool inherit) where T : Attribute;
static member GetCustomAttributes : System.Reflection.ParameterInfo * bool -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As ParameterInfo, inherit As Boolean) As IEnumerable(Of T)
類型參數
- T
要搜尋的屬性類型。
參數
- element
- ParameterInfo
要檢查的參數。
- inherit
- Boolean
true
表示檢查element
的祖系,否則為false
。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 T
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。
public:
generic <typename T>
where T : Attribute[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T> (this System.Reflection.MemberInfo element, bool inherit) where T : Attribute;
static member GetCustomAttributes : System.Reflection.MemberInfo * bool -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As MemberInfo, inherit As Boolean) As IEnumerable(Of T)
類型參數
- T
要搜尋的屬性類型。
參數
- element
- MemberInfo
要檢查的成員。
- inherit
- Boolean
true
表示檢查element
的祖系,否則為false
。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 T
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定參數。
public:
generic <typename T>
where T : Attribute[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T> (this System.Reflection.ParameterInfo element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.ParameterInfo -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As ParameterInfo) As IEnumerable(Of T)
類型參數
- T
要搜尋的屬性類型。
參數
- element
- ParameterInfo
要檢查的參數。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 T
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定成員。
public:
generic <typename T>
where T : Attribute[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T> (this System.Reflection.MemberInfo element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.MemberInfo -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As MemberInfo) As IEnumerable(Of T)
類型參數
- T
要搜尋的屬性類型。
參數
- element
- MemberInfo
要檢查的成員。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 T
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
element
不是建構函式、方法、屬性、事件、型別或欄位。
無法載入自訂屬性型別。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定組件。
public:
generic <typename T>
where T : Attribute[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::Assembly ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T> (this System.Reflection.Assembly element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.Assembly -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As Assembly) As IEnumerable(Of T)
類型參數
- T
要搜尋的屬性類型。
參數
- element
- Assembly
要檢查的組件。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 T
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
擷取指定型別的自訂屬性集合,此集合套用至指定模組。
public:
generic <typename T>
where T : Attribute[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::Module ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T> (this System.Reflection.Module element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.Module -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As Module) As IEnumerable(Of T)
類型參數
- T
要搜尋的屬性類型。
參數
- element
- Module
要檢查的模型。
傳回
自訂屬性的集合,這些屬性已套用至 element
且符合 T
;如果沒有這類屬性存在,則為空集合。
例外狀況
element
為 null
。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |