FieldInfo.FieldType Property
.NET Framework 4
Gets the type of this field object.
Assembly: mscorlib (in mscorlib.dll)
The following example creates a field, gets its type and FieldInfo, and displays its FieldType.
using System; using System.Reflection; // Make a field. public class Myfield { private string field = "private field"; } public class Myfieldinfo { public static int Main() { Console.WriteLine ("\nReflection.FieldInfo"); Myfield Myfield = new Myfield(); // Get the type and FieldInfo. Type MyType = typeof(Myfield); FieldInfo Myfieldinfo = MyType.GetField("field", BindingFlags.Instance|BindingFlags.NonPublic); // Get and display the FieldType. Console.Write ("\n{0}.", MyType.FullName); Console.Write ("{0} - ", Myfieldinfo.Name); Console.Write ("{0};", Myfieldinfo.GetValue(Myfield)); Console.Write ("\nFieldType = {0}", Myfieldinfo.FieldType); return 0; } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.