FieldInfo::MemberType Property
Gets a MemberTypes value indicating that this member is a field.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Reflection::MemberTypesA MemberTypes value indicating that this member is a field.
This property overrides MemberType. Therefore, when you examine a set of MemberInfo objects — for example, the array returned by GetMembers — the MemberType property returns MemberTypes::Field only when a given member is a field.
The following example determines whether the specified member is a field and displays the result.
using namespace System; using namespace System::Reflection; // Make a field. public ref class Myfield { private: String^ field; public: Myfield() : field( "a private field" ) {} property String^ Field { String^ get() { return field; } } }; int main() { Console::WriteLine( "\nReflection.FieldInfo" ); Myfield^ myfield = gcnew Myfield; // Get the Type and FieldInfo. Type^ MyType = Type::GetType( "Myfield" ); FieldInfo^ Myfieldinfo = MyType->GetField( "field", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) ); // Get and display the MemberType. Console::Write( "\n{0}.", MyType->FullName ); Console::Write( "{0} - ", Myfieldinfo->Name ); Console::Write( "{0};", myfield->Field ); MemberTypes Mymembertypes = Myfieldinfo->MemberType; Console::Write( "MemberType is a {0}.", Mymembertypes ); return 0; }
This code produces the following output:
Reflection.FieldInfo
Myfield.field - a private field; MemberType is a Field
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0