Difference
between Identifier and Keyword in C#
-
S.No
IdentifierKeyword1Meaning: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.2What it consists of ?Must be any combination of letters, numbers, and underscores.What it consists of ?Must be only letters.
3Upper 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.4Whether 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# keywords5Whether 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:
Thank you very much for your appreciation.
ReplyDeletePlease let me know if you need any difference between Q&A in particular.
"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"