A small example of converting a string to a variable name and getting the value of a variable in c
- 2020-05-19 05:32:01
- OfStack
public class Program
{
public string str = "spp";
public string spp = "Hello World!";
public static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine(p.GetType().GetField(p.str).GetValue(p).ToString());
Console.ReadKey();
}
}