我想在C#中这样做,但我不知道如何:
我有一个类名为-eg的字符串:FooClass我想在这个类上调用(静态)方法:
FooClass.MyMethod();
Run Code Online (Sandbox Code Playgroud)
显然,我需要通过反思找到对类的引用,但是如何?
请考虑这个课程:
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";
}
Run Code Online (Sandbox Code Playgroud)
我想编写一个获得"F1"并返回"18-25"的函数.例如
private string GetValue(string PropertyName)
....
Run Code Online (Sandbox Code Playgroud)
我该怎么做?