Friday, August 29, 2008

INTRODUCTION TO C#

Microsoft developed C# , late in 1990's and was the part of Microsoft's overall .NET startegy.It was first released in its alpha version in the middle of 2000. C#'s chief architect was Anders Hejlsberg, one of the world's leading language expert with several notable accomplishments to his credits. He was the author of Turbo Pascal.
C# is directly related to C, C++ and java. This is not by accident. Since it was neither neccessary nor desirable for Hejlsberg to "reinvent the wheel", he was free to focus on specific improvement and innovations.

The grandfather of C# is C. From C, it derives its syntax, many of keywords and its operators. C# builds upon and improves the object model defined by C++. If you know C or C++ , you feel at home with C#.
C# and java have a bit more complicated relationship. As explained, java is also descended from C and C++. It too shares the C/C++ syntax and object model. Like java, C# is designed to produce portable code. However C#is not descended from java. Instead they are more like cousins and share common ancestory.

.NET FRAMEWORK

The .net framework defines an environment that supports the developement and execution of highly distributed, component based applications. it enables differing computer languages to work together and provides security, program interoperability , program compatibility and a common programming model for the windows platform.
.Net frame work defines two very important entities

1. CLR (Common Language Runtime): This is the system that manages the execution of your system. Along with other benefits , it also enables a program to be portable, supports mixed language programming and provides security.

2. CLS(Common Language Specification): This gives your program to access to access the runtime environments. For example if you want to perform I/O, such as displaying something on screen, you will use.NET class library to do it.

HOW CLR WORKS

When you compile a C# program, the output of the compiler is not a executable code. Instead, it is a file that ciontains a special type of pseudocode called Microsoft Intermediate Language(MSIL). MSIL defines a portable assembly language . It is similar to the concept of java's byte code but the two are not same. MSIL is CPU independent. So it can run on any CPU architecture.

MSIL is then converted into executable code using JIT Compiler. When a .NET program is executed , the CLR activates the JIT Compiler. The JIT then converts MSIL into native code on a demand basis as each part of your program is needed.

MANAGED CODE VS UNMANAGED CODE

In general, when you are writing a C# program, you are craeting what is called a managed code. managed code is what that runs under the control of CLR.
Unmanaged code do not run under the control of CLR.

THE COMMON LANGUAGE SPECIFICATION

The CLS describes a set of feature that different languages have in common. It includes a subset of CTS(Common Type System). CTS defines rules concerning data types. For example. If we are writing am app in C# that will communicate with app written C++, then what CTS will do it will set a bridge between both datatype of C# and C++ for communication.

0 comments: