编写了一个方法:
void calc(object sender,EventArgs e)
{
double answer;
Button pressedbutton=(Button)sender;
switch(pressedbutton)
{
case"Button1":
answer=Convert.ToDouble(TextBox1.Text)+Convert.ToDouble(TextBox2.Text);
break;
}
}
在页面的source中的按钮控件中调用此方法,运行后出错提示:Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0151: A value of an integral type expectedSource Error: Line 19: double answer;
Line 20: Button pressedbutton = (Button)sender;
Line 21: switch (pressedbutton)
Line 22: {
Line 23:
void calc(object sender,EventArgs e)
{
double answer;
Button pressedbutton=(Button)sender;
switch(pressedbutton)
{
case"Button1":
answer=Convert.ToDouble(TextBox1.Text)+Convert.ToDouble(TextBox2.Text);
break;
}
}
在页面的source中的按钮控件中调用此方法,运行后出错提示:Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0151: A value of an integral type expectedSource Error: Line 19: double answer;
Line 20: Button pressedbutton = (Button)sender;
Line 21: switch (pressedbutton)
Line 22: {
Line 23:
解决方案 »
- 如何判断一个Web页面是否在屏幕的最前端?
- asp.net 怎么控制播放声音?
- 实在是郁闷了!!为什么CheckBoxList选中装备传不过来????
- 100分求教,ASP.NET只要调用存储过程就出错,找不出原因??
- 现在的ASP.NET网站一般用什么工具做啊?
- 请教高手,asp.net中如何实现超长文章自动分页套打
- ASP.NET中怎么连接ACCESS数据库(注:数据库不在本地机器上,在别的机器上)
- 一个关于验证控件的问题
- 本人新建一个.net的交流群.进来看看吧
- 如何实现在地址栏输入公司域名则自动跳转至公司模板页------在线等!!!!(最后的10分家产,见详情)
- 外国服务器,不支持中文,文件格式另存为的步骤是什么啊?
- 请问这是怎么回事?未能加载类型“WebApplication4.Global”
switch(pressedbutton.id)
text和id注意大小写
而case后面必须是常量,即如果后面跟str的话,前面是const string str = "abc"就行,但如果前面是public string str = "abc"就不行。当然一般我们都直接写值如"abc"。