开发者

How to define a Property that it's the keyword like 'checked'?

Who can help me to resolve the question? When I defined the Property 'checked' in a class,It's always not passed.

Example:
   public class Node
    {
        public bool checked
        {
            get;set;
        }
    }

I do so because of I am开发者_如何学Python using a jquery plugin which the return json object's property is checked

I will be very grateful if somebody help me Thank you


If you want to use a reserved word as an identifier (which you should avoid anyway), prefix it with the @ symbol. So your code would be:

public class Node
{
    public bool @checked
    {
        get;set;
    }
}

Unfortunately, this also means you will need to use the @ symbol when referencing the property. It also won't appear in Visual Studio's IntelliSense listing.


You can't put this keyword in front of a variable declaration like readonly. See how to use the checked keyword. I think you want:

public int MyProperty
{
  get
  {
    checked
    {
       //maybe a overflow here
    }
    //non-checked code here
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜