Datasheet
Part I: The C# Language
8
practically forgotten about when completed. This also makes it easy to locate specific pieces of code
when you need them and enables teams of developers to divide up the programming burden into
manageable chunks, whereby individuals can “ check out ” pieces of code to work on without risking
damage to otherwise satisfactory sections or sections other people are working on.
What Is C#?
C#, as mentioned earlier, is one of the languages you can use to create applications that will run in the
.NET CLR. It is an evolution of the C and C++ languages and has been created by Microsoft specifically
to work with the .NET platform. Because it is a recent development, the C# language has been designed
with hindsight, taking into account many of the best features from other languages, while clearing up
their problems.
Developing applications using C# is simpler than using C++, because the language syntax is simpler.
Still, C# is a powerful language, and there is little you might want to do in C++ that you can ’ t do in C#.
Having said that, those features of C# that parallel the more advanced features of C++, such as directly
accessing and manipulating system memory, can only be carried out using code marked as unsafe . This
advanced programmatic technique is potentially dangerous (hence its name), because it is possible to
overwrite system - critical blocks of memory with potentially catastrophic results. For this reason, and
others, this book does not cover that topic.
At times, C# code is slightly more verbose than C++. This is a consequence of C# being a type - safe
language (unlike C++). In layperson ’ s terms, this means that once some data has been assigned to a type,
it cannot subsequently transform itself into another unrelated type. Consequently, strict rules must be
adhered to when converting between types, which means you will often need to write more code to
carry out the same task in C# than you might write in C++, but you get two benefits: the code is more
robust and debugging is simpler, and .NET can always track the type of a piece of data at any time.
In C#, you therefore may not be able to do things such as “ take the region of memory 4 bytes into this
data and 10 bytes long and interpret it as X, ” but that ’ s not necessarily a bad thing.
C# is just one of the languages available for .NET development, but it is certainly the best. It has the
advantage of being the only language designed from the ground up for the .NET Framework and may
be the principal language used in versions of .NET that are ported to other operating systems. To keep
languages such as the .NET version of Visual Basic as similar as possible to their predecessors yet
compliant with the CLR, certain features of the .NET code library are not fully supported. By contrast,
C# can make use of every feature that the .NET Framework code library has to offer. The latest version of
.NET includes several improvements to the C# language, partly in response to requests from developers,
making it even more powerful.
Applications You Can Write with C#
The .NET Framework has no restrictions on the types of applications that are possible, as discussed
earlier. C# uses the framework and therefore has no restrictions on possible applications. However, here
are a few of the more common application types:
Windows applications: These are applications, such as Microsoft Office, that have a familiar
Windows look and feel about them. This is made simple by using the Windows Forms module
of the .NET Framework, which is a library of controls (such as buttons, toolbars, menus, and so
on) that you can use to build a Windows user interface (UI).
❑
CH001.indd 8CH001.indd 8 10/22/10 3:43:51 PM10/22/10 3:43:51 PM