mardi 25 avril 2017

How do you access fields of a static class with reflection?

I have a class like this:

public static class MyThing
{
    public const string MyString = "Hello World!";
    public const int MyInt = 10;
}

Given the strings:

string s1 = "MyString";
string s2 = "MyInt";

How do I access the string "Hello World!" and the int 3? i'm guessing I have to use reflection, but so far have not found anything that works.





Aucun commentaire:

Enregistrer un commentaire