Type.IsEquivalentTo(Type) 方法

定義

判斷兩個 COM 類型是否具有相同的識別以及是否適合類型等價。Determines whether two COM types have the same identity and are eligible for type equivalence.

public:
 virtual bool IsEquivalentTo(Type ^ other);
public virtual bool IsEquivalentTo (Type? other);
public virtual bool IsEquivalentTo (Type other);
abstract member IsEquivalentTo : Type -> bool
override this.IsEquivalentTo : Type -> bool
Public Overridable Function IsEquivalentTo (other As Type) As Boolean

參數

other
Type

進行測試以確定是否和目前類型等價的 COM 類型。The COM type that is tested for equivalence with the current type.

傳回

Boolean

如果 COM 型別為等價則為 true,否則為 falsetrue if the COM types are equivalent; otherwise, false. 如果一個類型位於已載入來執行的組件中,而另一個類型位於已載入至純反映性的內容的組件中,這個方法也會傳回 falseThis method also returns false if one type is in an assembly that is loaded for execution, and the other is in an assembly that is loaded into the reflection-only context.

備註

從 .NET Framework 4 開始,common language runtime 支援將 COM 類型的類型資訊直接內嵌到 managed 元件,而不需要 managed 元件從 interop 元件取得 COM 類型的類型資訊。Beginning with the .NET Framework 4, the common language runtime supports the embedding of type information for COM types directly into managed assemblies, instead of requiring the managed assemblies to obtain type information for COM types from interop assemblies. 因為內嵌類型資訊僅包含 Managed 組件實際所使用的類型和成員,所以兩個 Managed 組件可能對於相同的 COM 類型會有非常不同的檢視。Because the embedded type information includes only the types and members that are actually used by a managed assembly, two managed assemblies might have very different views of the same COM type. 每個 Managed 組件有不同的 Type 物件以代表其 COM 類型檢視。Each managed assembly has a different Type object to represent its view of the COM type. 通用語言執行平台支援介面、結構、列舉和委派等這些不同檢視之間的類型等價。The common language runtime supports type equivalence between these different views for interfaces, structures, enumerations, and delegates.

類型等價表示從一個 Managed 組件傳到另一個的 COM 物件,可以在接收的組件中轉換成適當的 Managed 類型。Type equivalence means that a COM object that is passed from one managed assembly to another can be cast to the appropriate managed type in the receiving assembly. IsEquivalentTo方法可讓元件判斷從另一個元件取得的 com 物件,其 com 身分識別與第一個元件本身的內嵌 interop 類型相同,因此可以轉換成該類型。The IsEquivalentTo method enables an assembly to determine that a COM object obtained from another assembly has the same COM identity as one of the first assembly's own embedded interop types, and thus can be cast to that type.

如需詳細資訊,請參閱 類型等價和內嵌 Interop 類型For more information, see Type Equivalence and Embedded Interop Types.

適用於