using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
public partial class test2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var type = typeof(FormBLL).GetType();
var fieldInfos = type.GetFields(BindingFlags.Instance |
BindingFlags.Static |
BindingFlags.NonPublic |
BindingFlags.Public);
var q = fieldInfos.ToList();
foreach(var f in q)
{
Response.Write(f.Name + "<br/>");
}
}
public static class FormBLL
{
public static string @event = "abc";
public static string adduserlocation = "123";
}
}
答案 0 :(得分:1)
typeof(FormBLL).GetType()
是System.RuntimeType
。你不需要那里的GetType
。 typeof(FormBLL)
就足够了
var type = typeof(FormBLL);
var fieldInfos = type.GetFields(BindingFlags.Instance |
BindingFlags.Static |
BindingFlags.NonPublic |
BindingFlags.Public);