Appendix A. Keywords in C#

Keywords are reserved and cannot be used as identifiers. If you really want to choose a C# keyword as an identifier name, prefix it with a @. [1] For example, @new is a legal identifier but new is not.

[1] Highly discouraged by myself - there are lots of other words you can choose for your identifiers.

Table A.1 shows the list of C# keywords, and the chapters in which they are described in this book. Of all the C# keywords, only extern and stackalloc are beyond the scope of this book.

Table A.1. C# keywords
KeywordCommentsChapter
abstractModifier – used to declare a class or class member as abstract6
asOperator – a convenient combination of the typeof and is operators10
baseUsed to invoke a constructor in the super(base)class7
boolSimple type9
breakLooping11
byteSimple type9
caseDecision – used together with switch11
catchException handling13
charSimple type9
checkedException handling13
classType – used to declare a class type6
constModifier – used to declare a field as constant8
continueLooping11
decimalSimple type9
defaultDecision – used together with switch and case11
delegateModifier – used to declare a delegate type14
doLooping11
doubleSimple type9
elseDecision – used together with if11
enumType – used to declare an enum type25
eventModifier – used to declare an event instance15
explicitModifier – used to user-defined casts/conversions to declare that a user-defined cast is to be explicit23
externModifier – to declare that a method implementation is in some external library-
falseValue for boolean9
finallyException handling13
fixedUsed to mark a block of codes in a class which contains members which has pointer variables referencing them29
floatSimple type9
forLooping11
foreachLooping11
gotoLooping11
ifDecision making11
implicitModifier – used to user-defined casts/conversions to declare that a user-defined cast is to be implicit23
inLooping – used only together with foreach11
intSimple type8
interfaceType – used to declare an interface type6
internalAccess modifier8
isOperator – used to check if an object is of a particular type6
lockMarks a code block as a critical section17
longSimple type9
namespaceUsed to define a namespace5
newUsed to create a new object or struct – also used in name overriding6/7/26
nullLiteral for reference types6
objectAlias for System.Object6
operatorModifier – used to declare a method for operator overloading22
outUsed to pass parameters by reference in methods7
overrideModifier – to declare a method as overriding a virtual one in a superclass7
paramsType – used to pass in a variable number of method parameters7
privateAccess modifier8
protectedAccess modifier8
publicAccess modifier8
readonlyModifier – used to declare a field as read-only8
refUsed to pass parameters by reference in methods7
returnTo return from a method call7
sbyteSimple type9
sealedModifier – used to declare a class which cannot be subclassed, or method which cannot be overridden6/7
shortSimple type9
sizeofOperator – returns the size of a struct (including simple types) in number of bytes10
stackallocUsed in unsafe coding to allocate space on the stack manually-
staticModifier – used to declare a class member as static8/9
stringAlias for System.String9
structType – used to declare a structure type26
switchDecision making11
thisRepresents the current object6
throwException handling13
trueValue for boolean9
tryException handling13
typeofOperator – to return a System.Type instance representing the type of an object10
uintSimple type9
ulongSimple type9
uncheckedException handling13
unsafeModifier – used to mark unsafe methods, classes, structs, class members, and an arbitrary block of code which contains pointer operations29
ushortSimple type9
usingUsed to import a namespace5
virtualModifier – to declare a method as overridable in a subclass7
volatileModifier – used to declare volatile fields8
voidReturn type for a method7
whileLooping11

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.196.172