Type.MemberType 屬性

定義

取得一個 MemberTypes 值,代表這個成員是類型或巢狀類型。Gets a MemberTypes value indicating that this member is a type or a nested type.

public:
 virtual property System::Reflection::MemberTypes MemberType { System::Reflection::MemberTypes get(); };
public override System.Reflection.MemberTypes MemberType { get; }
member this.MemberType : System.Reflection.MemberTypes
Public Overrides ReadOnly Property MemberType As MemberTypes

屬性值

一個 MemberTypes 值,代表這個成員是類型或巢狀類型。A MemberTypes value indicating that this member is a type or a nested type.

實作

範例

下列程式碼範例會將 MemberType 欄位顯示為 GetMember 方法的參數:The following code example shows the MemberType field as a parameter to the GetMember method:

array<MemberInfo^>^ others = t->GetMember( mi->Name, mi->MemberType,
   (BindingFlags)(BindingFlags::Public | BindingFlags::Static |
      BindingFlags::NonPublic | BindingFlags::Instance) );
MemberInfo[] others = t.GetMember(mi.Name, mi.MemberType, BindingFlags.Public |
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance);
Dim others As MemberInfo() = t.GetMember(mi.Name, mi.MemberType, _
BindingFlags.Public Or BindingFlags.Static Or BindingFlags.NonPublic _
Or BindingFlags.Instance)

備註

這個屬性會覆寫 MemberInfo.MemberTypeThis property overrides MemberInfo.MemberType. 因此,當您檢查一組 MemberInfo 物件(例如,由 GetMembers 傳回的陣列)時,MemberType 屬性會在指定的成員是巢狀型別時傳回 MemberTypes.NestedTypeTherefore, when you examine a set of MemberInfo objects - for example, the array returned by GetMembers - the MemberType property returns MemberTypes.NestedType when a given member is a nested type.

如果目前的 Type 代表結構化的泛型型別,這個屬性會套用至用來建立類型的泛型型別定義。If the current Type represents a constructed generic type, this property applies to the generic type definition from which the type was constructed. 例如,如果目前的 Type 表示 Visual Basic 中的 MyGenericType<int>MyGenericType(Of Integer)),則這個屬性的值是由 MyGenericType<T>所決定。For example, if the current Type represents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.

如果目前 Type 表示泛型型別或泛型方法定義中的類型參數,則這個屬性一律會傳回 MemberTypes.TypeInfoIf the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns MemberTypes.TypeInfo.

適用於

另請參閱