Word Choice

It’s wise to avoid using class names duplicated in heavily used namespaces. For instance, do not use the following for a class name:

System       Collections   Forms       UI

Also avoid using identifiers that conflict with common keywords; remember that all keywords must be escapable (and therefore usable) within any .NET language, but that doesn’t mean it’s easy to do. Avoid the identifier names listed in Table 22-1.

Table 22-1. Common keywords best avoided in class names

AddHandler

AddressOf

Alias

And

Ansi

As

Assembly

Auto

BitAnd

BitNot

BitOr

BitXor

Boolean

ByRef

Byte

ByVal

Call

Case

Catch

CBool

CByte

CChar

CDate

CDec

CDbl

Char

CInt

Class

CLng

CObj

Const

CShort

CSng

CStr

CType

Date

Decimal

Declare

Default

Delegate

Dim

Do

Double

Each

Else

ElseIf

End

Enum

Erase

Error

Eval

Event

Exit

Extends

ExternalSource

False

Finally

For

Friend

Function

Get

GetType

Goto

Handles

If

Implements

Imports

In

Inherits

Integer

Interface

Is

InstanceOf

Let

Lib

Like

Long

Loop

Me

Mod

Module

MustInherit

MustOverride

MyBase

MyClass

Namespace

New

Next

Not

Nothing

NotInheritable

NotOverridable

Object

On

Option

Optional

Or

Overloads

Overridable

Overrides

Package

ParamArray

Preserve

Private

Property

Protected

Public

RaiseEvent

ReadOnly

ReDim

Region

REM

RemoveHandler

Resume

Return

Select

Set

Shadows

Shared

Short

Single

Static

Step

Stop

String

Structure

Sub

SyncLock

Then

Throw

To

True

Get C# in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.