15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

62 ❘ ChaPTer 2 cOre c#<br />

Names <strong>and</strong> Keywords<br />

It is important that the names do not clash with any keywords. In fact, if you attempt to name an item<br />

in your code with a word that happens to be a <strong>C#</strong> keyword, you’ll almost certainly get a syntax error<br />

because the compiler will assume that the name refers to a statement. However, because of the possibility<br />

that your classes will be accessed by code written in other languages, it is also important that you don’t<br />

use names that are keywords in other .<strong>NET</strong> languages. Generally speaking, C++ keywords are similar<br />

to <strong>C#</strong> keywords, so confusion with C++ is unlikely, <strong>and</strong> those commonly encountered keywords that are<br />

unique to Visual C++ tend to start with two underscore characters. As with <strong>C#</strong>, C++ keywords are spelled<br />

in lowercase, so if you hold to the convention of naming your public classes <strong>and</strong> members with Pascalstyle<br />

names, they will always have at least one uppercase letter in their names, <strong>and</strong> there will be no risk<br />

of clashes with C++ keywords. However, you are more likely to have problems with Visual Basic .<strong>NET</strong>,<br />

which has many more keywords than <strong>C#</strong> does, <strong>and</strong> being non-case–sensitive means that you cannot rely on<br />

Pascal-style names for your classes <strong>and</strong> methods.<br />

The following table lists the keywords <strong>and</strong> st<strong>and</strong>ard function calls in Visual Basic .<strong>NET</strong>, which you should<br />

avoid, if possible, in whatever case combination, for your public <strong>C#</strong> classes.<br />

Abs Do Loc RGB<br />

Add Double Local Right<br />

AddH<strong>and</strong>ler Each Lock RmDir<br />

AddressOf Else LOF Rnd<br />

Alias ElseIf Log RTrim<br />

And Empty Long SaveSettings<br />

Ansi End Loop Second<br />

AppActivate Enum LTrim Seek<br />

Append EOF Me Select<br />

As Erase Mid SetAttr<br />

Asc Err Minute SetException<br />

Assembly Error MIRR Shared<br />

Atan Event MkDir Shell<br />

Auto Exit Module Short<br />

Beep Exp Month Sign<br />

Binary Explicit MustInherit Sin<br />

BitAnd ExternalSource MustOverride Single<br />

BitNot False MyBase SLN<br />

BitOr FileAttr MyClass Space<br />

BitXor FileCopy Namespace Spc<br />

Boolean FileDateTime New Split<br />

ByRef FileLen Next Sqrt<br />

Byte Filter Not Static<br />

ByVal Finally Nothing Step<br />

Call Fix NotInheritable Stop<br />

Case For NotOverridable Str<br />

Catch Format Now StrComp<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!