//Get type of MyClass
Type myType = Type.GetType("MyNamespace.MyClass");
//Get PropertyInfo for property SomeProperty
PropertyInfo pi = myType.GetProperty("SomeProperty");
//Display property value on console.
//Because it's static you can pass nulls for both object and index
Console.WriteLine("Value of my property is: " +
pi.GetValue(null, null));
Tuesday, 1 July 2008
Accessing static properties using C# reflections
Subscribe to:
Posts (Atom)