如何通过代码判断变量为 static
namespace test
{
class test1
{
public static Object obj = new object();
public static void Main(string [] arg)
{
Type t = obj.GetType();
System.Console.Write(t.FullName);
}
}
}
Type test1Type = typeof(test1);
var fieldInfo = programType.GetField("obj");
var isStatic = fieldInfo.IsStatic;
正解
来晚了
学到新东西了