9.22.2012

Identifier vs Keyword in C#

Difference between Identifier and Keyword in C#
S.No
Identifier
Keyword
1
Meaning:
A C# identifier is a name given to a class, delegate, interface, method, namespace or variable.
Meaning:
Keywords are predefined reserved identifiers that have special meanings to the compiler.
2
What it consists of ?
Must be any combination of letters, numbers, and underscores.
What it consists of ?
Must be only letters.


3
Upper case / Lower case / Both ?
Allows both Uppercase and Lowercase.
Upper case / Lower case / Both ?
Most of the keywords are Lowercase.But,only Namespaces, Types and Members have their first character in uppercase.
4
Whether Unicode characters are allowed or not ?
Identifiers can begin with an allowed Unicode character or an underline. But,we need to use nonformatting Unicode characters in any part of an identifier.
i.e., u0027format // error – Unicode formatting character which is not allowed.
Whether Unicode characters are allowed or not ?
Unicode characters are not used in any C# keywords
5
Whether it can be used to name classes, methods, or variables ?
The purpose of Identifier is to provide names to namespaces, classes, methods, variables, and interfaces.
Whether it can be used to name classes, methods, or variables ?
We cannot use keywords for naming classes, methods, or variables.

Note: Keywords cannot be used as identifiers in your program unless they include the "at" sign (@) as a prefix. For example, @new would be a legal identifier; but, new is not, because it is a keyword.

References:








5 comments:

  1. Thanks for sharing this information with us. Your material is up to date and quite informative, I would like to bookmark this page so I can come here to read this again, as you have done a wonderful job.

    PIC Scheme

    ReplyDelete
  2. Thank you very much for your appreciation.

    Please let me know if you need any difference between Q&A in particular.

    ReplyDelete
  3. "Nice and good article.. it is very useful for me to learn and understand easily.. thanks for sharing your valuable information and time.. please keep updating.php jobs in hyderabad.
    "

    ReplyDelete