【发布时间】:2015-07-28 17:29:41
【问题描述】:
无法将 lambda 表达式转换为 bool 类型,因为它不是委托类型。
protected void button1_Click(object sender, EventArgs e)
{
int totalpoints;
Int32 realpoints;
lelpoints = 0;
totalpoints = Convert.ToInt32(dPts.Text);
totalpoints = totalpoints + 1;
totalpoints = realpoints;
dPts.Text = totalpoints.ToString();
}
protected void buyBG_Click(object sender, EventArgs e)
{
string[] rbg = new string[] { "red", "green", "blue" };
Random random = new Random();
int randomNumber = random.Next(0, 3);
string currentbg = rbg[randomNumber];
if (realpoints => 10 ){}
这是我在使用上面提供的代码时遇到的问题。问题显示在底部的 If 语句中。
编辑:将=> 更改为>= 肯定解决了该问题,但现在它报告错误“名称 realpoints 在当前上下文中不存在”。谢谢
【问题讨论】:
-
切换
=和>。=>生成一个 lambda,>=是“大于或等于”运算符。由于简单的印刷错误,投票以离题结束。 -
在您的编辑中:是的,我也看到了那个。在修复错误的方法之外定义
realpoints。如果您还有其他问题,请提出新问题。 -
谢谢,如果出现更多问题,我会提出一个新问题。麻烦您了,这个问题已经结束了。