【问题标题】:Error: "; expected", can't find where I'm missing it错误:“;预期”,找不到我错过的地方
【发布时间】:2011-01-14 05:25:21
【问题描述】:

我正在使用一个公共部分类来扩展一些 LINQ TO SQL 类,并且在我 [第一次尝试] 添加一个奇怪的属性时遇到了上述错误,不确定我是否做得对。 :S

无论如何,代码如下:

public partial class Round
{
    public int PlayersInRound
    {
        get { return this.RoundMembers.Count(); }
    }

    public bool PlayerIsInRound(string sUsername)
    {
        get { return ((from x in this._RoundMembers where x.Member.Email == sUsername select x).Count() >= 1); }
    }
}

VS IDE 为倒数第三行的“{”添加了红色下划线,我不知道为什么。第一个添加的似乎可以正常工作,但我不完全确定它是否可以,因为我还没有建立足够多的网站,我也不真的知道如何到目前为止还要做TDD。 :P

非常感谢,伙计们! :)

【问题讨论】:

  • 哇,没关系。看起来 不知何故 我不小心在 this.RoundMembers 区域添加了一个下划线,这就是它的原因。我不知道那是怎么到那里的..现在,我怎样才能将这个问题标记为已关闭? xD
  • 只要接受以下答案之一,它就会“关闭”。 :-)

标签: c# asp.net-mvc public partial-classes


【解决方案1】:

您的错误在于PlayerIsInRound:您正在将方法与属性混合

删除get{}

public bool PlayerIsInRound(string sUsername)
{
    return ((from x in this._RoundMembers where x.Member.Email == sUsername select x).Count() >= 1);
}

【讨论】:

  • 哦,那我该怎么做呢?
  • 这解决了我的问题,谢谢!不过,我还得再等大约 7 分钟才能将其标记为完成。我将打开标签页,以免忘记! :P
猜你喜欢
  • 2017-01-24
  • 1970-01-01
  • 2023-03-18
  • 1970-01-01
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 2021-10-20
  • 1970-01-01
相关资源
最近更新 更多