Mega Code Archive

 
Categories / C# / Reflection
 

FieldInfo GetValue Method returns the value of a field supported by a given object

using System; 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));     } }