FieldInfo.MemberType Property

Gets a value that indicates that this member is a field.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public override MemberTypes MemberType { get; }

Property Value

Type: System.Reflection.MemberTypes
A value that indicates that this member is a field.


This member is invoked late-bound through mechanisms such as Type.InvokeMember.

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 each instance member of the Example class is a field and displays the result.

using System;
using System.Reflection;

// Make a field.
public class Example
   private string m_field = "a private field";

   public string Field   
         return m_field;

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
      outputBlock.Text += "Reflection.FieldInfo\n\n";

      MemberInfo[] instanceMembers = 
         typeof(Example).GetMembers(BindingFlags.Public | BindingFlags.NonPublic | 
      foreach( MemberInfo mi in instanceMembers )
         if (mi.MemberType == MemberTypes.Field)
            outputBlock.Text += String.Format("{0} is a field. <----\n", mi.Name);
            outputBlock.Text += String.Format("{0} is not a field. \n", mi.Name);

/* This example produces the following output:


get_Field is not a field. 
ToString is not a field. 
Equals is not a field. 
GetHashCode is not a field. 
GetType is not a field. 
Finalize is not a field. 
MemberwiseClone is not a field. 
.ctor is not a field. 
Field is not a field. 
m_field is a field. <----


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions