Information Technology Reference
In-Depth Information
Naming Conventions
The C# Language Specification suggests that certain casing conventions be used in creating
identifiers. The suggested guidelines for casing are described and summarized in Table 2-2.
For most identifiers, the Pascal casing style should be used. In this style, each of the words
combined to make an identifier is capitalized—for example, FirstName and LastName .
Table 2-2. Recommended Identifier Naming Styles
Style Name
Description
Recommended Use
Examples
CardDeck ,
DealersHand
Pascal casing
Each word in the identifier
is capitalized.
Use for most identifiers.
totalCycleCount ,
randomSeedParam
Camel casing
Each word in the identifier,
except the first , is capitalized.
Use for parameters and
local variables.
IO , DMA , XML
Uppercase
The identifier is composed
of all uppercase letters.
Use only for abbreviations.
Keywords
Keywords are the character string tokens used to define the C# language. A complete list of the
C# keywords is given in Table 2-3.
Some important things to know about keywords are the following:
￿
Keywords cannot be used as variable names or any other form of identifier, unless pref-
aced with the @ character.
￿
All C# keywords consist entirely of lowercase letters. .NET type names, however, use
Pascal casing.
Table 2-3. The C# Keywords
abstract const
extern
int
out
short
typeof
as
continue false
interface override
sizeof
uint
base
decimal
finally
internal
params
stackalloc ulong
bool
default
fixed
is
private
static
unchecked
break
delegate float
lock
protected string
unsafe
byte
do
for
long
public
struct
ushort
case
double
foreach
namespace readonly
switch
using
catch
else
goto
new
ref
this
virtual
char
enum
if
null
return
throw
void
checked
event
implicit object
sbyte
true
volatile
class
explicit in
operator
sealed
try
while
Search WWH ::




Custom Search