Field value
In this chapter you will learn:
Get field value
FieldInfo.GetValue
nethod returns the value of a field supported by a given object.
using System;//from ja va2s . c o m
using System.Reflection;
class MyClass
{
public static String val = "test";
public static void Main()
{
FieldInfo myf = typeof(MyClass).GetField("val");
Console.WriteLine(myf.GetValue(null));
val = "hi";
Console.WriteLine(myf.GetValue(null));
}
}
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Reflection