本文介绍了字段启动器不能引用非静态字段?错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 protected void Page_Load(对象发​​件人,EventArgs e) { double startCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); if (!IsPostBack) {} } double endCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); double totalSeconds = Convert.ToDouble(endCounter - startCounter); Response.Write(totalSeconds); } 请帮帮我解决方案 这些行 double endCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); double totalSeconds = Convert.ToDouble(endCounter - startCounter); Response.Write(totalSeconds); 不在方法范围内,将它们移入; 受保护 void Page_Load( object sender,EventArgs e) { double startCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); if (!IsPostBack) {} double endCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); double totalSeconds = Convert.ToDouble(endCounter - startCounter); Response.Write(totalSeconds); } 希望这会有所帮助, Fredrik protected void Page_Load(object sender, EventArgs e) { double startCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); if (!IsPostBack) { } } double endCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); double totalSeconds = Convert.ToDouble( endCounter - startCounter); Response.Write(totalSeconds);}please help me 解决方案 These linesdouble endCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds);double totalSeconds = Convert.ToDouble( endCounter - startCounter);Response.Write(totalSeconds);Are not inside the scope of the method, move them in;protected void Page_Load(object sender, EventArgs e){ double startCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); if (!IsPostBack) { } double endCounter = Convert.ToDouble(DateTime.Now.TimeOfDay.TotalSeconds); double totalSeconds = Convert.ToDouble( endCounter - startCounter); Response.Write(totalSeconds);}Hope this helps,Fredrik 这篇关于字段启动器不能引用非静态字段?错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-27 16:12