CustomAttributeExtensions.GetCustomAttribute CustomAttributeExtensions.GetCustomAttribute CustomAttributeExtensions.GetCustomAttribute CustomAttributeExtensions.GetCustomAttribute Method

定義

擷取套用至指定之項目的自訂屬性。Retrieves a custom attribute that is applied to a specified element.

多載

GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type)

擷取指定型別的自訂屬性,此屬性套用至指定組件。Retrieves a custom attribute of a specified type that is applied to a specified assembly.

GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type)

擷取指定型別的自訂屬性,此屬性套用至指定成員。Retrieves a custom attribute of a specified type that is applied to a specified member.

GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type)

擷取指定型別的自訂屬性,此屬性套用至指定模組。Retrieves a custom attribute of a specified type that is applied to a specified module.

GetCustomAttribute(ParameterInfo, Type) GetCustomAttribute(ParameterInfo, Type) GetCustomAttribute(ParameterInfo, Type) GetCustomAttribute(ParameterInfo, Type)

擷取指定型別的自訂屬性,此屬性套用至指定參數。Retrieves a custom attribute of a specified type that is applied to a specified parameter.

GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.

GetCustomAttribute(ParameterInfo, Type, Boolean) GetCustomAttribute(ParameterInfo, Type, Boolean) GetCustomAttribute(ParameterInfo, Type, Boolean) GetCustomAttribute(ParameterInfo, Type, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定參數,並且可選擇性檢查該參數的祖系。Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.

GetCustomAttribute<T>(ParameterInfo, Boolean) GetCustomAttribute<T>(ParameterInfo, Boolean) GetCustomAttribute<T>(ParameterInfo, Boolean) GetCustomAttribute<T>(ParameterInfo, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定參數,並且可選擇性檢查該參數的祖系。Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.

GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.

GetCustomAttribute<T>(ParameterInfo) GetCustomAttribute<T>(ParameterInfo) GetCustomAttribute<T>(ParameterInfo) GetCustomAttribute<T>(ParameterInfo)

擷取指定型別的自訂屬性,此屬性套用至指定參數。Retrieves a custom attribute of a specified type that is applied to a specified parameter.

GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module)

擷取指定型別的自訂屬性,此屬性套用至指定模組。Retrieves a custom attribute of a specified type that is applied to a specified module.

GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo)

擷取指定型別的自訂屬性,此屬性套用至指定成員。Retrieves a custom attribute of a specified type that is applied to a specified member.

GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly)

擷取指定型別的自訂屬性,此屬性套用至指定組件。Retrieves a custom attribute of a specified type that is applied to a specified assembly.

GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type)

擷取指定型別的自訂屬性,此屬性套用至指定組件。Retrieves a custom attribute of a specified type that is applied to a specified assembly.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::Assembly ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.Assembly element, Type attributeType);
static member GetCustomAttribute : System.Reflection.Assembly * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Assembly, attributeType As Type) As Attribute

參數

element
Assembly Assembly Assembly Assembly

要檢查的組件。The assembly to inspect.

attributeType
Type Type Type Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

符合 attributeType 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches attributeType, or null if no such attribute is found.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

找到一個以上要求的屬性。More than one of the requested attributes was found.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type)

擷取指定型別的自訂屬性,此屬性套用至指定成員。Retrieves a custom attribute of a specified type that is applied to a specified member.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::MemberInfo ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.MemberInfo element, Type attributeType);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type) As Attribute

參數

element
MemberInfo MemberInfo MemberInfo MemberInfo

要檢查的成員。The member to inspect.

attributeType
Type Type Type Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

符合 attributeType 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches attributeType, or null if no such attribute is found.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type)

擷取指定型別的自訂屬性,此屬性套用至指定模組。Retrieves a custom attribute of a specified type that is applied to a specified module.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::Module ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.Module element, Type attributeType);
static member GetCustomAttribute : System.Reflection.Module * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Module, attributeType As Type) As Attribute

參數

element
Module Module Module Module

要檢查的模型。The module to inspect.

attributeType
Type Type Type Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

符合 attributeType 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches attributeType, or null if no such attribute is found.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

找到一個以上要求的屬性。More than one of the requested attributes was found.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute(ParameterInfo, Type) GetCustomAttribute(ParameterInfo, Type) GetCustomAttribute(ParameterInfo, Type) GetCustomAttribute(ParameterInfo, Type)

擷取指定型別的自訂屬性,此屬性套用至指定參數。Retrieves a custom attribute of a specified type that is applied to a specified parameter.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::ParameterInfo ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.ParameterInfo element, Type attributeType);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type) As Attribute

參數

element
ParameterInfo ParameterInfo ParameterInfo ParameterInfo

要檢查的參數。The parameter to inspect.

attributeType
Type Type Type Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

符合 attributeType 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches attributeType, or null if no such attribute is found.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::MemberInfo ^ element, Type ^ attributeType, bool inherit);
public static Attribute GetCustomAttribute (this System.Reflection.MemberInfo element, Type attributeType, bool inherit);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type, inherit As Boolean) As Attribute

參數

element
MemberInfo MemberInfo MemberInfo MemberInfo

要檢查的成員。The member to inspect.

attributeType
Type Type Type Type

要搜尋的屬性類型。The type of attribute to search for.

inherit
Boolean Boolean Boolean Boolean

true 表示檢查element的祖系,否則為falsetrue to inspect the ancestors of element; otherwise, false.

傳回

符合 attributeType 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches attributeType, or null if no such attribute is found.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute(ParameterInfo, Type, Boolean) GetCustomAttribute(ParameterInfo, Type, Boolean) GetCustomAttribute(ParameterInfo, Type, Boolean) GetCustomAttribute(ParameterInfo, Type, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定參數,並且可選擇性檢查該參數的祖系。Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::ParameterInfo ^ element, Type ^ attributeType, bool inherit);
public static Attribute GetCustomAttribute (this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type, inherit As Boolean) As Attribute

參數

element
ParameterInfo ParameterInfo ParameterInfo ParameterInfo

要檢查的參數。The parameter to inspect.

attributeType
Type Type Type Type

要搜尋的屬性類型。The type of attribute to search for.

inherit
Boolean Boolean Boolean Boolean

true 表示檢查element的祖系,否則為falsetrue to inspect the ancestors of element; otherwise, false.

傳回

符合 attributeType 的自訂屬性,如果找不到這樣的屬性則為 nullA custom attribute matching attributeType, or null if no such attribute is found.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute<T>(ParameterInfo, Boolean) GetCustomAttribute<T>(ParameterInfo, Boolean) GetCustomAttribute<T>(ParameterInfo, Boolean) GetCustomAttribute<T>(ParameterInfo, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定參數,並且可選擇性檢查該參數的祖系。Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::ParameterInfo ^ element, bool inherit);
public static T GetCustomAttribute<T> (this System.Reflection.ParameterInfo element, bool inherit) where T : Attribute;
static member GetCustomAttribute : System.Reflection.ParameterInfo * bool -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo, inherit As Boolean) As T

類型參數

T

要搜尋的屬性類型。The type of attribute to search for.

參數

element
ParameterInfo ParameterInfo ParameterInfo ParameterInfo

要檢查的參數。The parameter to inspect.

inherit
Boolean Boolean Boolean Boolean

true 表示檢查element的祖系,否則為falsetrue to inspect the ancestors of element; otherwise, false.

傳回

T T T T

符合 T 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches T, or null if no such attribute is found.

例外狀況

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean)

擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::MemberInfo ^ element, bool inherit);
public static T GetCustomAttribute<T> (this System.Reflection.MemberInfo element, bool inherit) where T : Attribute;
static member GetCustomAttribute : System.Reflection.MemberInfo * bool -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo, inherit As Boolean) As T

類型參數

T

要搜尋的屬性類型。The type of attribute to search for.

參數

element
MemberInfo MemberInfo MemberInfo MemberInfo

要檢查的成員。The member to inspect.

inherit
Boolean Boolean Boolean Boolean

true 表示檢查element的祖系,否則為falsetrue to inspect the ancestors of element; otherwise, false.

傳回

T T T T

符合 T 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches T, or null if no such attribute is found.

例外狀況

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute<T>(ParameterInfo) GetCustomAttribute<T>(ParameterInfo) GetCustomAttribute<T>(ParameterInfo) GetCustomAttribute<T>(ParameterInfo)

擷取指定型別的自訂屬性,此屬性套用至指定參數。Retrieves a custom attribute of a specified type that is applied to a specified parameter.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::ParameterInfo ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.ParameterInfo element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.ParameterInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo) As T

類型參數

T

要搜尋的屬性類型。The type of attribute to search for.

參數

element
ParameterInfo ParameterInfo ParameterInfo ParameterInfo

要檢查的參數。The parameter to inspect.

傳回

T T T T

符合 T 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches T, or null if no such attribute is found.

例外狀況

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module)

擷取指定型別的自訂屬性,此屬性套用至指定模組。Retrieves a custom attribute of a specified type that is applied to a specified module.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::Module ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.Module element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.Module -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Module) As T

類型參數

T

要搜尋的屬性類型。The type of attribute to search for.

參數

element
Module Module Module Module

要檢查的模型。The module to inspect.

傳回

T T T T

符合 T 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches T, or null if no such attribute is found.

例外狀況

找到一個以上要求的屬性。More than one of the requested attributes was found.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo)

擷取指定型別的自訂屬性,此屬性套用至指定成員。Retrieves a custom attribute of a specified type that is applied to a specified member.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::MemberInfo ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.MemberInfo element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.MemberInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo) As T

類型參數

T

要搜尋的屬性類型。The type of attribute to search for.

參數

element
MemberInfo MemberInfo MemberInfo MemberInfo

要檢查的成員。The member to inspect.

傳回

T T T T

符合 T 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches T, or null if no such attribute is found.

例外狀況

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

找到一個以上要求的屬性。More than one of the requested attributes was found.

無法載入自訂屬性型別。A custom attribute type cannot be loaded.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly)

擷取指定型別的自訂屬性,此屬性套用至指定組件。Retrieves a custom attribute of a specified type that is applied to a specified assembly.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::Assembly ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.Assembly element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.Assembly -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Assembly) As T

類型參數

T

要搜尋的屬性類型。The type of attribute to search for.

參數

element
Assembly Assembly Assembly Assembly

要檢查的組件。The assembly to inspect.

傳回

T T T T

符合 T 的自訂屬性,如果找不到這類屬性,則為 nullA custom attribute that matches T, or null if no such attribute is found.

例外狀況

找到一個以上要求的屬性。More than one of the requested attributes was found.

備註

如果您預期會傳回一個以上的值,請使用 GetCustomAttributes 擴充方法,否則將擲回 AmbiguousMatchExceptionUse the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.

適用於