find and solve || findandsolve.com
Please wait.....

Keywords and Identifiers in C#



In C#,you work with certain predefined and user-defined words or names.The words or names that are predefined are called keywords, while those that are user-defined are called identifiers. An identifier is the name that you give to the programming elements created in a program.For example,the names that you give to the variables and arrays are identifiers. A variable is a placeholder to store a single value of a particular kind,An array is an ordered collection of a particular kind of values.

Note that you cannot define an identifier that is same as a keyword.This is because keywords are those words,which are defined in the programming language to perform a particular task or indicate some programming aspect,such as creating a class. C# has many keywords that are automatically recognize by its compiler.In C# there are two types of keyword,reserved and contextual. A reserved keyword performs the same predefined task wherever you use it in your C# program; whereas,a contextual keyword may perform different task based on the context in which you use it.

Although it is not recommended,but you can use keywords as identifier.To use a reserved or contextual keyword (inside it's context) as an identifier,you need to prefix the @ character with the identifier. However,you can directly use a contextual keyword outside its context as an identifier.


Reserved Keywords

abstract
break
as
byte
base
case
bool
catch
charcheckedclassconst
continuedecimaldefaultdelegate
dodoubleelseenum
eventexplicitexternfalse
finallyfixedfloatfor
foreachgotoifimplicit
inintinterfaceinternal
islocklongnamespace
newnullobjectoperator 
outoverrideparamsprivate
protectedpublicreadonlyref
returnsbytesealedshort
sizeofstackallocstatic string
structswitchthisthrow
truetrytypeofuint
ulonguncheckedunsefeushort
usingvirtualvoidvolatile
while

Contextual keyword

add
 
   alias

ascending

descending
dynamic     fromgetgloabl
group       intojoinlet
orderby     partial(type)partial (method)remove
select     setvaluevar
where(generic type constraint)     where (query clause)yield


Sundar  Neupane

Sundar Neupane

I like working on projects with a team that cares about creating beautiful and usable interfaces.

If findandsolve.com felt valuable to you, feel free to share it.

Comments



Report Response