Sams Teach Yourself C in 21 Days

(singke) #1
The C# Programming Language 767

BD7



  • C# is modular.

  • C# will be popular.


C# Is Simple ..................................................................................................


C# removes some of the complexities and pitfalls of languages such as C++, including
the removal of macros, templates, multiple inheritance, and virtual base classes. These
are all areas that cause either confusion or potential problems for C++ developers. If you
are learning C# as your first language, rest assured—these are topics you won’t have to
spend time learning!
C# is simple for many to learn because it is based on C and C++. If you are familiar with
C and C++—or even Java—you will find C# very familiar in many aspects. Statements,
expressions, operators, and other functions are taken directly from C and C++, but
improvements make the language simpler. Some of the improvements include eliminat-
ing redundancies. Other areas of improvement include additional syntax changes. For
example, C++ has three operators for working with members: ::,., and ->. Knowing
when to use each of these three symbols can be very confusing in C++. In C#, these are
all replaced with a single symbol—the “dot” operator. For newer programmers, this and
many other features eliminate a lot of confusion.

C# Is Modern ................................................................................................


What makes a modern language? Features such as exception handling, garbage collec-
tion, extensible data types, and code security are features that are expected in a modern
language. C# contains all of these.

As you learned on day 9, pointers are an integral part of C. They are also the
most confusing part of languages like C and C++. C# removes much of the
complexity and trouble caused by pointers. In C#, there are automatic fea-
tures that take care of working with data types and pointers. A feature
called garbage collection occurs automatically. Garbage collection makes
sure that pointers and memory are freed when they are no longer needed.

Note


C# Is Object-Oriented ..................................................................................


The keys to an object-oriented language are encapsulation, inheritance, and polymor-
phism. You learned about these concepts when covering C++ and Java. C# supports all of
these as well. Remember,encapsulationis the placing of functionality into a single pack-
age.Inheritanceis a structured way of extending existing code and functionality into
new programs and packages. Polymorphismis the capability of adapting to what needs to
be done.

42 448201x-Bonus7 8/13/02 11:24 AM Page 767

Free download pdf