C# FieldInfo MemberType
Description
FieldInfo MemberType
Gets a MemberTypes value indicating
that this member is a field.
Syntax
FieldInfo.MemberType
has the following syntax.
public override MemberTypes MemberType { get; }
Example
The following example determines whether the specified member is a field and displays the result.
/* w w w . j ava 2 s . co m*/
using System;
using System.Reflection;
public class Myfield
{
private string field = "a private field";
public string Field
{
get{return field;}
}
}
public class Myfieldinfo
{
public static int Main()
{
Myfield Myfield = new Myfield();
Type MyType = typeof(Myfield);
FieldInfo Myfieldinfo = MyType.GetField("field", BindingFlags.NonPublic|BindingFlags.Instance);
MemberTypes Mymembertypes = Myfieldinfo.MemberType;
Console.Write("MemberType is a {0}.", Mymembertypes.ToString());
return 0;
}
}
The code above generates the following result.