Keywords and Operators

C# keywords are reserved words with special meaning in C# programs. C# also has several operators for performing bitwise, logical, and mathematical operations. Those familiar with C, C++, or Java will recognize the similarities of these operators. Also, note that C# is case sensitive. The fields (variables) myInt and MyInt are two distinct identifiers, and whereas double is a keyword, Double is a valid variable name.

C# Keywords

Table 2.2 shows all the keywords available for C#. Although C# keywords may not be used as identifiers (variable and type names), an exception to this rule is if the keyword were prefixed with an @ symbol. Although I wouldn't recommend it, @if and other keywords prefixed with @ could be used as identifiers.

Table 2.2. Complete List of C# Keywords

abstract

as

base

bool

break

byte

case

catch

char

checked

class

const

continue

decimal

default

delegate

do

double

else

enum

event

explicit

extern

false

finally

fixed

float

for

foreach

goto

if

implicit

in

int

interface

internal

is

lock

long

namespace

new

null

object

operator

out

override

params

private

protected

public

readonly

ref

return

sbyte

sealed

short

sizeof

stackalloc

static

string

struct

switch

this

throw

true

try

typeof

uint

ulong

unchecked

unsafe

ushort

using

virtual

void

volatile

while

   

Most of the keywords in Table 2.2 will be used throughout this book, and I'll explain each one when it is applicable. Full coverage of every keyword is beyond the scope of this book.

C# Operators

The C# operators, shown in Table 2.3, are very similar to those of C, C++, and Java. They offer the ability to create bitwise, logical, and mathematical operations.

Table 2.3. Operator Precedence and Associativity

OPERATORS

ASSOCIATIVITY

x.y f(x) a[x] x++ x-- new typeof checked unchecked

Left

+(unary) -(unary) ! ~ ++x --x (T)x

Left

* / %

Left

+(arithmetic) -(arithmetic)

Left

<< >>

Left

< > <= >= is as

Left

== !=

Left

&

Left

^

Left

|

Left

&&

Left

||

Left

?:

Right

= *= /= %= += -= <<= >>= &= ^= |=

Right



C# Builder KickStart
C# Builder KickStart
ISBN: 672325896
EAN: N/A
Year: 2003
Pages: 165

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