This article focuses on the new ways of programming
C# offers, and how it intends to improve upon its two closest
neighbors, Java and C++. C# improves on C++ in a similar way to Java in
many respects, so I'm not going to be re-explaining things like the
benefits of a single-rooted object hierarchy. This article begins with a
brief summary of the similarities between C# and Java, and then goes
into exploring the new C# features. You can convert PDF to word if necessary to get a printable view of the article.
Below is a list of features C# and Java share, which are intended to improve on C++. These features are not the focus of this article, but it is very important to be aware of the similarities.
Background
In June 2000, Microsoft announced both the .NET platform and a new
programming language called C#. C# is a strongly-typed object-oriented
language designed to
give the optimum blend of simplicity, expressiveness, and performance.
The .NET platform is
centered around a Common Language Runtime (similar to a JVM) and a set
of libraries which can be exploited by a wide variety of languages which
are able to work
together by all compiling to an intermediate language (IL). C# and .NET
are a little symbiotic: some features of C# are there to work well with
.NET, and some
features of .NET are there to work well with C# (though .NET aims to
work well with many languages). Projects created with C# and .NET are
usually compatible with
most web hosting providers. This article
is mostly concerned with C#, but
sometimes it
is useful to discuss .NET too. The C# language was built with the hindsight of many languages,
but most notably Java and C++. It was co-authored by Anders Hejlsberg
(who is famous for the design of the Delphi language), and Scott
Wiltamuth.Below is a list of features C# and Java share, which are intended to improve on C++. These features are not the focus of this article, but it is very important to be aware of the similarities.
- Compiles into machine-independent language-independent code which runs in a managed execution environment.
- Garbage Collection coupled with the elimination of pointers (in C# restricted use is permitted within code marked unsafe)
- Powerful reflection capabilities
- No header files, all code scoped to packages or assemblies, no problems declaring one class before another with circular dependencies
- Classes all descend from object and must be allocated on the heap with new keyword
- Thread support by putting a lock on objects when entering code marked as locked/synchronized
- Interfaces, with multiple-inheritance of interfaces, single inheritance of implementations
- Inner classes
- No concept of inheriting a class with a specified access level
- No global functions or constants, everything belongs to a class
- Arrays and strings with lengths built-in and bounds checking
- The '.' operator is always used, no more ->, :: operators
- null and boolean/bool are keywords
- All values are initialized before use
- Can't use integers to govern if statements
- Try Blocks can have a finally clause
1 comments:
Write commentshmmm
Reply