Please consider this class:
public static class Age
{
public static readonly string F1 = "18-25";
public static readonly string F2 = "26-35";
public static readonly string F3 = "36-45";
public static readonly string F4 = "46-55";
}
I wanto to write a function that get “F1” and return “18-25”.for example
private string GetValue(string PropertyName)
....
How can I do it?
You can simply use
SWITCHstatement to perform above task:Using Reflection, you can do like this: