asp.net中反射问题!
public class index : System.Web.UI.Page
{
protected string i12= "asdf ";
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
Type typ1=typeof(index);
object ss=typ1.GetField( "i12 ").GetValue(this);
Response.Write(ss.ToString());
}
}
}
这样会抱错,如要实现使用反射取得i12的值。怎么操作。谢谢
------解决方案--------------------string v = "123 ";
Type type = v.GetType();
MethodInfo info = type.GetMethod( "ToString ", new Type[0]);
Response.Write(info.Invoke(v,null).ToString());
------解决方案--------------------public string i12 = "asdf ";