Friday, November 23, 2012

Key Features of C-Sharp(C#)


Key Features of C-Sharp(C#)

  • Simple :
                It simplifies C++ by eliminating irk some operator such as ->, : : and pointers. 
  • Consistent : 
                   It support an unified type system which eliminates the problem of varying ranges of integer types. All types are treated as object and developers can extend the type system simply and easily.
  • Modern :
                      It supports, Automatic garbage collection, modern approach to debugging, rich intrinsic model for error handling, decimal data type for financial application and robust security model.
  • Object-Oriented:
                         It support all the three tenets of object-oriented system, namely Encapsulation, Inheritance and Polymorphism.
  • Type-Safe :
                        Type safety promotes robust programs, C# incorporates a number of type-safe measures :-
                                All dynamically allocated object and arrays are initialized to zero.
                                Use of any uninitialized variables produces an error message by the compilers
                                Access to array are range checked and warned if it  goes out-of-bounds.
                                C# does not permit unsafe casts.
                                C# enforces overflow checking in arithmetic’s operation.
                                Reference parameters that are passed are type-safe.
                                C# supports automatic garbage collection.
  • Versionable:
                               Making new versions of software modules work with the existing  applications is known as versioning with the help of new and override keywords, With this support, a programmer can guarantee that his new class library will maintain binary compatibility with the existing client application.
  • Compatible :
                           C# enforces the .NET common language specification and therefore allows interoperation with other .NET language.
  • Flexible :
                     Although C# does not support pointers we may declare certain classes and methods as ‘unsafe’ and then use pointers to manipulates them. These codes are not be type-safe.
  • Inter-Operability :
                               C# provides support for using COM objects, no matter what language was used to author them. C# also supports a special features that enables a program to call out any native API.



CLR Architecture

CLR Architecture

         





The source code that is written is compiled to an intermediate code called the byte code(in java) or the Common Intermediate Language(in .Net). Either the Java Virtual Machine or the Common Language Runtime (CLR) is used to compile the code to the intermediate form.

While executing the program, i.e., the intermediate code, the Just-In-Time(JIT) compiler comes into the picture. The job of the JIT compiler is to convert intermediate code in to the machine code or the native code for execution. With the JIT the code can be optimized to a  particular operating system. This is one of the advantages of going for such code execution.

The advantage of converting the source code to the intermediate code is that it can un or any operating system provided that the JIT for that operating system is present. This gives the portability of the code.
In .Net the CLR which also has the JIT is used to convert the CIL code into the native code to be processed by the machine. It is also possible to convert the source code to the native code directly by bypassing the tasks done by the JIT. This helps to reduce the load in the JIT.

Responsibility of CLR

It is responsible for loading and running C# programs. The CLR provides a number of services :-

Thanks :-Sumith