- What is .NET ?
programming language, C# (pronounced “see sharp”), specifically for this new platform. C# is a programming
language whose core syntax looks very similar to the syntax of Java. However, to call C# a Java rip-off is inaccurate. Both C# and Java are members of the C family of programming languages
(C, Objective C, C++, etc.) and therefore share a similar syntax. Just as Java is in many ways a
cleaned-up version of C++, C# can be viewed as a cleaned-up version of Java.
The truth of the matter is that many of C#’s syntactic constructs are modeled after various
aspects of Visual Basic 6.0 and C++. For example, like VB6, C# supports the notion of formal type
properties (as opposed to traditional getter and setter methods) and the ability to declare methods
taking a varying number of arguments (via parameter arrays). Like C++, C# allows you to overload
operators, as well as to create structures, enumerations, and callback functions (via delegates).
Due to the fact that C# is a hybrid of numerous languages, the result is a product that is as syntactically
clean—if not cleaner—than Java, is about as simple as VB6, and provides just about as
much power and flexibility as C++ (without the associated ugly bits). Here is a partial list of core C#
features that are found in all versions of the language:
• No pointers required! C# programs typically have no need for direct pointer manipulation
(although you are free to drop down to that level if absolutely necessary).
• Automatic memory management through garbage collection. Given this, C# does not support
a delete keyword.
• Formal syntactic constructs for classes, interfaces, structures, enumerations, and delegates.
• The C++-like ability to overload operators for a custom type, without the complexity (e.g.,
making sure to “return *this to allow chaining” is not your problem).
• Support for attribute-based programming. This brand of development allows you to annotate
types and their members to further qualify their behavior.
With the release of .NET 2.0 (circa 2005), the C# programming language was updated to support
numerous new bells and whistles, most notably the following:
• The ability to build generic types and generic members. Using generics, you are able to build
very efficient and type-safe code that defines numerous “placeholders” specified at the time
you interact with the generic item.
• Support for anonymous methods, which allow you to supply an inline function anywhere a
delegate type is required.
• Numerous simplifications to the delegate/event model, including covariance, contravariance,
and method group conversion.
• The ability to define a single type across multiple code files (or if necessary, as an in-memory
representation) using the partial keyword.
As you might guess, .NET 3.5 adds even more functionality to the C# programming language
(C# 2008, to be exact), including the following features:
• Support for strongly typed queries (a la LINQ, or Language Integrated Query) used to interact
with various forms of data
• Support for anonymous types, which allow you to model the “shape” of a type rather than its
behavior
• The ability to extend the functionality of an existing type using extension methods
• Inclusion of a lambda operator (=>), which even further simplifies working with .NET delegate
types
• A new object initialization syntax, which allows you to set property values at the time of
object creation
Perhaps the most important point to understand about the C# language is that it can only produce
code that can execute within the .NET runtime (you could never use C# to build a native COM
server or an unmanaged Win32 API application). Officially speaking, the term used to describe the
code targeting the .NET runtime is managed code. The binary unit that contains the managed code
is termed an assembly (more details on assemblies in just a bit in the section “An Overview of .NET
Assemblies”). Conversely, code that cannot be directly hosted by the .NET runtime is termed
unmanaged code.
No comments:
Post a Comment