Appendix A. Keywords in C


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

Keyword

Comments

Chapter

abstract

Modifier “ used to declare a class or class member as abstract

6

as

Operator “ a convenient combination of the typeof and is operators

10

base

Used to invoke a constructor in the super(base)class

7

bool

Simple type

9

break

Looping

11

byte

Simple type

9

case

Decision “ used together with switch

11

catch

Exception handling

13

char

Simple type

9

checked

Exception handling

13

class

Type “ used to declare a class type

6

const

Modifier “ used to declare a field as constant

8

continue

Looping

11

decimal

Simple type

9

default

Decision “ used together with switch and case

11

delegate

Modifier “ used to declare a delegate type

14

do

Looping

11

double

Simple type

9

else

Decision “ used together with if

11

enum

Type “ used to declare an enum type

25

event

Modifier “ used to declare an event instance

15

explicit

Modifier “ used to user-defined casts/conversions to declare that a user -defined cast is to be explicit

23

extern

Modifier “ to declare that a method implementation is in some external library

-

false

Value for boolean

9

finally

Exception handling

13

fixed

Used to mark a block of codes in a class which contains members which has pointer variables referencing them

29

float

Simple type

9

for

Looping

11

foreach

Looping

11

goto

Looping

11

if

Decision making

11

implicit

Modifier “ used to user-defined casts/conversions to declare that a user-defined cast is to be implicit

23

in

Looping “ used only together with foreach

11

int

Simple type

8

interface

Type “ used to declare an interface type

6

internal

Access modifier

8

is

Operator “ used to check if an object is of a particular type

6

lock

Marks a code block as a critical section

17

long

Simple type

9

namespace

Used to define a namespace

5

new

Used to create a new object or struct “ also used in name overriding

6/7/26

null

Literal for reference types

6

object

Alias for System.Object

6

operator

Modifier “ used to declare a method for operator overloading

22

out

Used to pass parameters by reference in methods

7

override

Modifier “ to declare a method as overriding a virtual one in a superclass

7

params

Type “ used to pass in a variable number of method parameters

7

private

Access modifier

8

protected

Access modifier

8

public

Access modifier

8

readonly

Modifier “ used to declare a field as read-only

8

ref

Used to pass parameters by reference in methods

7

return

To return from a method call

7

sbyte

Simple type

9

sealed

Modifier “ used to declare a class which cannot be subclassed, or method which cannot be overridden

6/7

short

Simple type

9

sizeof

Operator “ returns the size of a struct (including simple types) in number of bytes

10

stackalloc

Used in unsafe coding to allocate space on the stack manually

-

static

Modifier “ used to declare a class member as static

8/9

string

Alias for System.String

9

struct

Type “ used to declare a structure type

26

switch

Decision making

11

this

Represents the current object

6

throw

Exception handling

13

true

Value for boolean

9

try

Exception handling

13

typeof

Operator “ to return a System.Type instance representing the type of an object

10

uint

Simple type

9

ulong

Simple type

9

unchecked

Exception handling

13

unsafe

Modifier “ used to mark unsafe methods, classes, structs, class members, and an arbitrary block of code which contains pointer operations

29

ushort

Simple type

9

using

Used to import a namespace

5

virtual

Modifier “ to declare a method as overridable in a subclass

7

volatile

Modifier “ used to declare volatile fields

8

void

Return type for a method

7

while

Looping

11



From Java to C#. A Developers Guide
From Java to C#: A Developers Guide
ISBN: 0321136225
EAN: 2147483647
Year: 2003
Pages: 221
Authors: Heng Ngee Mok

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net