vendredi 2 octobre 2020

Retrieve Static Property Value From Class Name

I have a static property that I need to access by name without instantiating the class.

THIS WORKS:

var importantVar = MyClass.MyStaticProperty;

THIS DOESN"T WORKS

var qualifiedName = "MyObjects.MyClass";
var theType = Type.GetType(qualifiedName);
var importantVar = (theType).MyStaticProperty;

theType returns null? How can I do this? Thanks!





Aucun commentaire:

Enregistrer un commentaire