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 表示 MyGenericType<int>MyGenericType(Of Integer) Visual Basic),则此属性的值由 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.

适用于

另请参阅