Results 1 to 4 of 4

Thread: Syntax Error for a variable named checked in Csharp

  1. #1
    Join Date
    Sep 2009
    Posts
    131

    Syntax Error for a variable named checked in Csharp

    I am new to the software programming concepts. But according to my academic syllabus I need to learn Csharp basics. But as I said I am completely a fresher for software programming and have no idea about this. I was given a program question in Csharp and I am getting an error which states syntax error. This happens whenever I declare a variable named checked in Csharp.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Syntax Error for a variable named checked in Csharp

    This is a very simple error. In programming languages such as C, C++, C# we are not allowed to use the keywords as variable name or class name or property name or name any user defined entity using the keywords. Since in C#, checked is a Keyword, hence you are not allowed to use it as name of a variable. Thus you are a getting the syntax error.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Syntax Error for a variable named checked in Csharp

    For C Sharp checked is a reserved word or a keyword. This keyword is required to check the overflow checking context in case of mathematical operations. A C Sharp programmer does not has the right to use keywords for declaring a variable. Therefore you get a syntax error for declaring the variable by checked name.

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Syntax Error for a variable named checked in Csharp

    We cannot make use of a keyword to declare it as a name for a variable in C#. Whenever we do so we are given a syntax error. In C# checked is a keyword that makes overflow-checking explicitly for operations of arithmatic intergral-type. So try not to use any keyword when you declare any variable in C#

Similar Threads

  1. What is a syntax error?
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 24-11-2009, 09:53 AM
  2. Variable method arguments in Csharp
    By KAMANA in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 05:57 PM
  3. Replies: 2
    Last Post: 28-08-2009, 07:51 PM
  4. PHP WordPress Parse Error: syntax error, unexpected $end in
    By Bisujaksha in forum Software Development
    Replies: 2
    Last Post: 22-05-2009, 09:27 AM
  5. DOS commands, Syntax Error
    By softte in forum Operating Systems
    Replies: 3
    Last Post: 17-02-2009, 03:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,678,671.35941 seconds with 17 queries