Choose Category
typeof(classname);
using System; using System.Reflection; namespace forgetCode { static class ReflectionTest { public static int Length; public static void Write() { //C# checks this at compile time itself Type type = typeof(ReflectionTest); // Get type pointer FieldInfo[] fields = type.GetFields(); // Obtain all fields foreach (var field in fields) // Loop through fields { string name = field.Name; // Get string name object temp = field.GetValue(null); // Get value if (temp is int) // See if it is an integer. { int value = (int)temp; Console.Write(name); Console.Write(" (int) = "); Console.WriteLine(value); } } } } class Program { static void Main() { ReflectionTest.Length = 100; // Set value ReflectionTest.Write(); // Invoke reflection methods } } }