FieldInfo.FieldType Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the type of this field object.

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

public abstract Type FieldType { get; }

Property Value

Type: System.Type

The type of this field object.

The type is some primitive data type, such as String, Boolean, or GUID.

To get the FieldType property, first get the class Type. From the Type, get the FieldInfo. From the FieldInfo, get the FieldType value.

The following example creates a field, gets its type and FieldInfo, and displays its FieldType.

using System;
using System.Reflection;

public class TestClass
    // Define a field.
    private string field = "private field";

public class Example
    public static void Main()
        var cl= new TestClass();

        // Get the type and FieldInfo.
        Type t = cl.GetType();
        FieldInfo fi = t.GetField("field", 
            BindingFlags.Instance | BindingFlags.NonPublic);

        // Get and display the field type.
        Console.WriteLine("Field Name: {0}.{1}", t.FullName, fi.Name);
        Console.WriteLine("Field Value: '{0}'", fi.GetValue(cl));
        Console.WriteLine("Field Type: {0}", fi.FieldType);
// The example displays the following output:
//       Field Name: TestClass.field
//       Field Value: 'private field'
//       Field Type: System.String

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top