tags:

views:

51

answers:

2

Hi everyone,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 using a jquery plugin which the return json object's property is checked

I will be very grateful if somebody help me Thank you

+1  A: 

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
  }
}
Danny Chen
I am sorry,maybe i don't explain the question clearly.
JejuneWolf
@JejuneWolf: It's not a good idea to use a keyword as a variable name. Simply change it to `Checked`.
Danny Chen
+5  A: 

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.

David Brown
Thank you your help,you are right,it passed to prefix it with the @ symbol
JejuneWolf