C# reflection? assign value to static variable changed by reflection?
Posted on 2010-09-15
How do I assign value to a static variable that the static variable is part of a string within
a class and it changes frequently?
Need actual code example: I've looked at several online posts of examples and cannot figure it out.
public static int ABCnumber;
public static int ABDnumber;
public static int ABEnumber;
//and over 200 of this combinations.
in different class
String stringname = (this changes frequently and could be over 200 different names)
(stringname would be ABC or ABD or ABE or other 200 names)
(the "number" part of static int would be constant and does not change, added as string?)
I want to assign an int to the public static int based on whatever the stringname is currently.
I think Reflection is how this is done but not sure?
Please list code example based on above and not online links.