FieldInfo.FieldType Property gets the type of this field object.
using System;
using System.Reflection;
public class Myfield
{
private string field = "private field";
}
public class Myfieldinfo
{
public static int Main()
{
Myfield Myfield = new Myfield();
Type MyType = typeof(Myfield);
FieldInfo Myfieldinfo = MyType.GetField("field", BindingFlags.Instance|BindingFlags.NonPublic);
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;
}
}
Related examples in the same category