Attribute Attribute Attribute Attribute Class

定義

代表自訂屬性的基底類別。Represents the base class for custom attributes.

public ref class Attribute abstract : System::Runtime::InteropServices::_Attribute
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Attribute : System.Runtime.InteropServices._Attribute
type Attribute = class
    interface _Attribute
Public MustInherit Class Attribute
Implements _Attribute
繼承
AttributeAttributeAttributeAttribute
衍生
屬性
實作

範例

下列程式碼範例示範使用AttributeThe following code example demonstrates the usage of Attribute.

using namespace System;
using namespace System::Reflection;

// An enumeration of animals. Start at 1 (0 = uninitialized).
public enum class Animal
{
    // Pets.
    Dog = 1,
    Cat, Bird
};

// A custom attribute to allow a target to have a pet.
public ref class AnimalTypeAttribute: public Attribute
{
public:

    // The constructor is called when the attribute is set.
    AnimalTypeAttribute( Animal pet )
    {
        thePet = pet;
    }


protected:

    // Keep a variable internally ...
    Animal thePet;

public:

    property Animal Pet 
    {
        // .. and show a copy to the outside world.
        Animal get()
        {
            return thePet;
        }

        void set( Animal value )
        {
            thePet = value;
        }
    }
};

// A test class where each method has its own pet.
ref class AnimalTypeTestClass
{
public:

    [AnimalType(Animal::Dog)]
    void DogMethod(){}


    [AnimalType(Animal::Cat)]
    void CatMethod(){}

    [AnimalType(Animal::Bird)]
    void BirdMethod(){}

};

int main()
{
    AnimalTypeTestClass^ testClass = gcnew AnimalTypeTestClass;
    Type^ type = testClass->GetType();

    // Iterate through all the methods of the class.
    System::Collections::IEnumerator^ myEnum = 
        type->GetMethods()->GetEnumerator();
    while ( myEnum->MoveNext() )
    {
        MethodInfo^ mInfo = safe_cast<MethodInfo^>(myEnum->Current);

        // Iterate through all the Attributes for each method.
        System::Collections::IEnumerator^ myEnum1 = 
            Attribute::GetCustomAttributes( mInfo )->GetEnumerator();
        while ( myEnum1->MoveNext() )
        {
            Attribute^ attr = safe_cast<Attribute^>(myEnum1->Current);

            // Check for the AnimalType attribute.
            if ( attr->GetType() == AnimalTypeAttribute::typeid )
                Console::WriteLine( "Method {0} has a pet {1} attribute.", 
                mInfo->Name, (dynamic_cast<AnimalTypeAttribute^>(attr))->Pet );
        }
    }
}

/*
 * Output:
 * Method DogMethod has a pet Dog attribute.
 * Method CatMethod has a pet Cat attribute.
 * Method BirdMethod has a pet Bird attribute.
 */
using System;
using System.Reflection;

// An enumeration of animals. Start at 1 (0 = uninitialized).
public enum Animal {
    // Pets.
    Dog = 1,
    Cat,
    Bird,
}

// A custom attribute to allow a target to have a pet.
public class AnimalTypeAttribute : Attribute {
    // The constructor is called when the attribute is set.
    public AnimalTypeAttribute(Animal pet) {
        thePet = pet;
    }

    // Keep a variable internally ...
    protected Animal thePet;

    // .. and show a copy to the outside world.
    public Animal Pet {
        get { return thePet; }
        set { thePet = value; }
    }
}

// A test class where each method has its own pet.
class AnimalTypeTestClass {
    [AnimalType(Animal.Dog)]
    public void DogMethod() {}

    [AnimalType(Animal.Cat)]
    public void CatMethod() {}

    [AnimalType(Animal.Bird)]
    public void BirdMethod() {}
}

class DemoClass {
    static void Main(string[] args) {
        AnimalTypeTestClass testClass = new AnimalTypeTestClass();
        Type type = testClass.GetType();
        // Iterate through all the methods of the class.
        foreach(MethodInfo mInfo in type.GetMethods()) {
            // Iterate through all the Attributes for each method.
            foreach (Attribute attr in
                Attribute.GetCustomAttributes(mInfo)) {
                // Check for the AnimalType attribute.
                if (attr.GetType() == typeof(AnimalTypeAttribute))
                    Console.WriteLine(
                        "Method {0} has a pet {1} attribute.",
                        mInfo.Name, ((AnimalTypeAttribute)attr).Pet);
            }

        }
    }
}
/*
 * Output:
 * Method DogMethod has a pet Dog attribute.
 * Method CatMethod has a pet Cat attribute.
 * Method BirdMethod has a pet Bird attribute.
 */
Imports System
Imports System.Reflection

Public Module CustomAttrVB

    ' An enumeration of animals. Start at 1 (0 = uninitialized).
    Public Enum Animal
        ' Pets
        Dog = 1
        Cat
        Bird
    End Enum

    ' Visual Basic requires the AttributeUsage be specified.
    ' A custom attribute to allow a target to have a pet.
    <AttributeUsage(AttributeTargets.Method)> _
    Public Class AnimalTypeAttribute
        Inherits Attribute

        ' The constructor is called when the attribute is set.
        Public Sub New(ByVal animal As Animal)
            Me.thePet = animal
        End Sub

        ' Keep a variable internally ...
        Protected thePet As Animal

        ' .. and show a copy to the outside world.
        Public Property Pet() As Animal
            Get
                Return thePet
            End Get
            Set(ByVal Value As Animal)
                thePet = Value
            End Set
        End Property

    End Class

    ' A test class where each method has its own pet.
    Class AnimalTypeTestClass

        <AnimalType(Animal.Dog)> _
        Public Sub DogMethod()
        End Sub

        <AnimalType(Animal.Cat)> _
        Public Sub CatMethod()
        End Sub

        <AnimalType(Animal.Bird)> _
        Public Sub BirdMethod()
        End Sub
    End Class

    ' The runtime test.
    Sub Main()
        Dim testClass As New AnimalTypeTestClass()
        Dim tcType As Type = testClass.GetType()
        Dim mInfo As MethodInfo
        ' Iterate through all the methods of the class.
        For Each mInfo In tcType.GetMethods()
            Dim attr As Attribute
            ' Iterate through all the attributes of the method.
            For Each attr In Attribute.GetCustomAttributes(mInfo)
                If TypeOf attr Is AnimalTypeAttribute Then
                    Dim attrCustom As AnimalTypeAttribute = _
                        CType(attr, AnimalTypeAttribute)
                    Console.WriteLine("Method {0} has a pet {1} attribute.", _
                         mInfo.Name(), attrCustom.Pet.ToString())
                End If
            Next
        Next
    End Sub
End Module

' Output:
' Method DogMethod has a pet Dog attribute.
' Method CatMethod has a pet Cat attribute.
' Method BirdMethod has a pet Bird attribute.

備註

Attribute類別預先定義的系統資訊或使用者定義自訂的資訊將與相關聯的目標項目。The Attribute class associates predefined system information or user-defined custom information with a target element. 目標項目可以是組件、 類別、 建構函式、 委派、 列舉、 事件、 欄位、 介面、 方法、 可攜式執行檔的模組、 參數、 屬性、 傳回值、 結構或另一個屬性。A target element can be an assembly, class, constructor, delegate, enum, event, field, interface, method, portable executable file module, parameter, property, return value, struct, or another attribute.

屬性所提供的資訊就是所謂的中繼資料。Information provided by an attribute is also known as metadata. 中繼資料可在執行階段檢查您的應用程式,來控制您的程式如何處理資料,或在執行階段所控制的外部工具之前如何您本身的應用程式處理或保留。Metadata can be examined at run time by your application to control how your program processes data, or before run time by external tools to control how your application itself is processed or maintained. 例如,.NET Framework 會預先定義和使用屬性類型來控制執行階段行為,而某些程式設計語言使用屬性型別表示不直接支援的.NET Framework 一般型別系統的語言功能。For example, the .NET Framework predefines and uses attribute types to control run-time behavior, and some programming languages use attribute types to represent language features not directly supported by the .NET Framework common type system.

所有的屬性類型直接或間接衍生自Attribute類別。All attribute types derive directly or indirectly from the Attribute class. 屬性可以套用至任何目標項目;多個屬性可以套用至相同的目標項目;從目標項目衍生的項目可以繼承屬性。Attributes can be applied to any target element; multiple attributes can be applied to the same target element; and attributes can be inherited by an element derived from a target element. 使用AttributeTargets類別,以指定要套用屬性的目標項目。Use the AttributeTargets class to specify the target element to which the attribute is applied.

Attribute類別提供方便的方法,來擷取並測試自訂屬性。The Attribute class provides convenient methods to retrieve and test custom attributes. 如需使用屬性的詳細資訊,請參閱套用屬性屬性For more information about using attributes, see Applying Attributes and Attributes.

建構函式

Attribute() Attribute() Attribute() Attribute()

初始化 Attribute 類別的新執行個體。Initializes a new instance of the Attribute class.

屬性

TypeId TypeId TypeId TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

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

擷取套用至指定之組件的自訂屬性。Retrieves a custom attribute applied to a specified assembly. 參數會指定組件,以及要搜尋的自訂屬性型別。Parameters specify the assembly and the type of the custom attribute to search for.

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

擷取套用至組件的自訂屬性。Retrieves a custom attribute applied to an assembly. 參數會指定組件、要搜尋的自訂屬性型別,以及忽略的搜尋選項。Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.

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

擷取套用至型別成員的自訂屬性。Retrieves a custom attribute applied to a member of a type. 參數會指定成員,以及要搜尋的自訂屬性型別。Parameters specify the member, and the type of the custom attribute to search for.

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

擷取套用至型別成員的自訂屬性。Retrieves a custom attribute applied to a member of a type. 參數會指定成員、要搜尋的自訂屬性型別,以及是否要搜尋成員的祖系。Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

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

擷取套用至模組的自訂屬性。Retrieves a custom attribute applied to a module. 參數會指定模組,以及要搜尋的自訂屬性型別。Parameters specify the module, and the type of the custom attribute to search for.

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

擷取套用至模組的自訂屬性。Retrieves a custom attribute applied to a module. 參數會指定模組、要搜尋的自訂屬性型別,以及忽略的搜尋選項。Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.

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

擷取套用至方法參數的自訂屬性。Retrieves a custom attribute applied to a method parameter. 參數會指定方法參數,以及要搜尋的自訂屬性型別。Parameters specify the method parameter, and the type of the custom attribute to search for.

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

擷取套用至方法參數的自訂屬性。Retrieves a custom attribute applied to a method parameter. 參數會指定方法參數、要搜尋的自訂屬性型別,以及是否要搜尋方法參數的祖系。Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.

GetCustomAttributes(Assembly) GetCustomAttributes(Assembly) GetCustomAttributes(Assembly) GetCustomAttributes(Assembly)

擷取套用至組件的自訂屬性陣列。Retrieves an array of the custom attributes applied to an assembly. 參數會指定組件。A parameter specifies the assembly.

GetCustomAttributes(Assembly, Boolean) GetCustomAttributes(Assembly, Boolean) GetCustomAttributes(Assembly, Boolean) GetCustomAttributes(Assembly, Boolean)

擷取套用至組件的自訂屬性陣列。Retrieves an array of the custom attributes applied to an assembly. 參數會指定組件和忽略的搜尋選項。Parameters specify the assembly, and an ignored search option.

GetCustomAttributes(Assembly, Type) GetCustomAttributes(Assembly, Type) GetCustomAttributes(Assembly, Type) GetCustomAttributes(Assembly, Type)

擷取套用至組件的自訂屬性陣列。Retrieves an array of the custom attributes applied to an assembly. 參數會指定組件,以及要搜尋的自訂屬性型別。Parameters specify the assembly, and the type of the custom attribute to search for.

GetCustomAttributes(Assembly, Type, Boolean) GetCustomAttributes(Assembly, Type, Boolean) GetCustomAttributes(Assembly, Type, Boolean) GetCustomAttributes(Assembly, Type, Boolean)

擷取套用至組件的自訂屬性陣列。Retrieves an array of the custom attributes applied to an assembly. 參數會指定組件、要搜尋的自訂屬性型別,以及忽略的搜尋選項。Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.

GetCustomAttributes(MemberInfo) GetCustomAttributes(MemberInfo) GetCustomAttributes(MemberInfo) GetCustomAttributes(MemberInfo)

擷取套用至型別成員的自訂屬性陣列。Retrieves an array of the custom attributes applied to a member of a type. 參數會指定成員。A parameter specifies the member.

GetCustomAttributes(MemberInfo, Boolean) GetCustomAttributes(MemberInfo, Boolean) GetCustomAttributes(MemberInfo, Boolean) GetCustomAttributes(MemberInfo, Boolean)

擷取套用至型別成員的自訂屬性陣列。Retrieves an array of the custom attributes applied to a member of a type. 參數會指定成員、要搜尋的自訂屬性型別,以及是否要搜尋成員的祖系。Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

GetCustomAttributes(MemberInfo, Type) GetCustomAttributes(MemberInfo, Type) GetCustomAttributes(MemberInfo, Type) GetCustomAttributes(MemberInfo, Type)

擷取套用至型別成員的自訂屬性陣列。Retrieves an array of the custom attributes applied to a member of a type. 參數會指定成員,以及要搜尋的自訂屬性型別。Parameters specify the member, and the type of the custom attribute to search for.

GetCustomAttributes(MemberInfo, Type, Boolean) GetCustomAttributes(MemberInfo, Type, Boolean) GetCustomAttributes(MemberInfo, Type, Boolean) GetCustomAttributes(MemberInfo, Type, Boolean)

擷取套用至型別成員的自訂屬性陣列。Retrieves an array of the custom attributes applied to a member of a type. 參數會指定成員、要搜尋的自訂屬性型別,以及是否要搜尋成員的祖系。Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

GetCustomAttributes(Module) GetCustomAttributes(Module) GetCustomAttributes(Module) GetCustomAttributes(Module)

擷取套用至模組的自訂屬性陣列。Retrieves an array of the custom attributes applied to a module. 參數會指定模組。A parameter specifies the module.

GetCustomAttributes(Module, Boolean) GetCustomAttributes(Module, Boolean) GetCustomAttributes(Module, Boolean) GetCustomAttributes(Module, Boolean)

擷取套用至模組的自訂屬性陣列。Retrieves an array of the custom attributes applied to a module. 參數會指定模組和忽略的搜尋選項。Parameters specify the module, and an ignored search option.

GetCustomAttributes(Module, Type) GetCustomAttributes(Module, Type) GetCustomAttributes(Module, Type) GetCustomAttributes(Module, Type)

擷取套用至模組的自訂屬性陣列。Retrieves an array of the custom attributes applied to a module. 參數會指定模組,以及要搜尋的自訂屬性型別。Parameters specify the module, and the type of the custom attribute to search for.

GetCustomAttributes(Module, Type, Boolean) GetCustomAttributes(Module, Type, Boolean) GetCustomAttributes(Module, Type, Boolean) GetCustomAttributes(Module, Type, Boolean)

擷取套用至模組的自訂屬性陣列。Retrieves an array of the custom attributes applied to a module. 參數會指定模組、要搜尋的自訂屬性型別,以及忽略的搜尋選項。Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.

GetCustomAttributes(ParameterInfo) GetCustomAttributes(ParameterInfo) GetCustomAttributes(ParameterInfo) GetCustomAttributes(ParameterInfo)

擷取套用至方法參數的自訂屬性陣列。Retrieves an array of the custom attributes applied to a method parameter. 參數會指定方法參數。A parameter specifies the method parameter.

GetCustomAttributes(ParameterInfo, Boolean) GetCustomAttributes(ParameterInfo, Boolean) GetCustomAttributes(ParameterInfo, Boolean) GetCustomAttributes(ParameterInfo, Boolean)

擷取套用至方法參數的自訂屬性陣列。Retrieves an array of the custom attributes applied to a method parameter. 參數會指定方法參數,以及是否要搜尋方法參數的祖系。Parameters specify the method parameter, and whether to search ancestors of the method parameter.

GetCustomAttributes(ParameterInfo, Type) GetCustomAttributes(ParameterInfo, Type) GetCustomAttributes(ParameterInfo, Type) GetCustomAttributes(ParameterInfo, Type)

擷取套用至方法參數的自訂屬性陣列。Retrieves an array of the custom attributes applied to a method parameter. 參數會指定方法參數,以及要搜尋的自訂屬性型別。Parameters specify the method parameter, and the type of the custom attribute to search for.

GetCustomAttributes(ParameterInfo, Type, Boolean) GetCustomAttributes(ParameterInfo, Type, Boolean) GetCustomAttributes(ParameterInfo, Type, Boolean) GetCustomAttributes(ParameterInfo, Type, Boolean)

擷取套用至方法參數的自訂屬性陣列。Retrieves an array of the custom attributes applied to a method parameter. 參數會指定方法參數、要搜尋的自訂屬性型別,以及是否要搜尋方法參數的祖系。Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

IsDefined(Assembly, Type) IsDefined(Assembly, Type) IsDefined(Assembly, Type) IsDefined(Assembly, Type)

判斷是否將任何自訂屬性套用至組件。Determines whether any custom attributes are applied to an assembly. 參數會指定組件,以及要搜尋的自訂屬性型別。Parameters specify the assembly, and the type of the custom attribute to search for.

IsDefined(Assembly, Type, Boolean) IsDefined(Assembly, Type, Boolean) IsDefined(Assembly, Type, Boolean) IsDefined(Assembly, Type, Boolean)

判斷是否將任何自訂屬性套用至組件。Determines whether any custom attributes are applied to an assembly. 參數會指定組件、要搜尋的自訂屬性型別,以及忽略的搜尋選項。Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.

IsDefined(MemberInfo, Type) IsDefined(MemberInfo, Type) IsDefined(MemberInfo, Type) IsDefined(MemberInfo, Type)

判斷是否將任何自訂屬性套用至型別成員。Determines whether any custom attributes are applied to a member of a type. 參數會指定成員,以及要搜尋的自訂屬性型別。Parameters specify the member, and the type of the custom attribute to search for.

IsDefined(MemberInfo, Type, Boolean) IsDefined(MemberInfo, Type, Boolean) IsDefined(MemberInfo, Type, Boolean) IsDefined(MemberInfo, Type, Boolean)

判斷是否將任何自訂屬性套用至型別成員。Determines whether any custom attributes are applied to a member of a type. 參數會指定成員、要搜尋的自訂屬性型別,以及是否要搜尋成員的祖系。Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

IsDefined(Module, Type) IsDefined(Module, Type) IsDefined(Module, Type) IsDefined(Module, Type)

判斷是否將任何指定型別的自訂屬性套用至模組。Determines whether any custom attributes of a specified type are applied to a module. 參數會指定模組,以及要搜尋的自訂屬性型別。Parameters specify the module, and the type of the custom attribute to search for.

IsDefined(Module, Type, Boolean) IsDefined(Module, Type, Boolean) IsDefined(Module, Type, Boolean) IsDefined(Module, Type, Boolean)

判斷是否將任何自訂屬性套用至模組。Determines whether any custom attributes are applied to a module. 參數會指定模組、要搜尋的自訂屬性型別,以及忽略的搜尋選項。Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.

IsDefined(ParameterInfo, Type) IsDefined(ParameterInfo, Type) IsDefined(ParameterInfo, Type) IsDefined(ParameterInfo, Type)

判斷是否將任何自訂屬性套用至方法參數。Determines whether any custom attributes are applied to a method parameter. 參數會指定方法參數,以及要搜尋的自訂屬性型別。Parameters specify the method parameter, and the type of the custom attribute to search for.

IsDefined(ParameterInfo, Type, Boolean) IsDefined(ParameterInfo, Type, Boolean) IsDefined(ParameterInfo, Type, Boolean) IsDefined(ParameterInfo, Type, Boolean)

判斷是否將任何自訂屬性套用至方法參數。Determines whether any custom attributes are applied to a method parameter. 參數會指定方法參數、要搜尋的自訂屬性型別,以及是否要搜尋方法參數的祖系。Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.

Match(Object) Match(Object) Match(Object) Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can be used to get the type information for an interface.

_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

適用於

執行緒安全性

此型別具備執行緒安全。This type is thread safe.

另請參閱