Introduction to C# - C# FOR BEGINNERS CRASH COURSE (2014)

C# FOR BEGINNERS CRASH COURSE (2014)

Chapter 1 Introduction to C#

1.1 Overview of C#

C# is an object oriented, type safe high level programming language. It has been developed by Microsoft during the development of the .NET framework. C# was developed for the Common Language Infrastructure (CLI), this infrastructure was created to allow programs from various other high level languages to work together without the need to rewrite those programs entirely. The CLI contains a various executable programs referred simply as executables and are housed and ran in a system called the runtime environment.

All the programs created in .Net framework execute in an environment that handles the runtime requirements. The Common Language Runtime (CLR) provides the virtual machine, which helps the programmers not to consider the CPU specifications. The class library and CLR make the .NET framework.

1.2 Programming features of C#

· It is simple, advanced, object oriented language

· It contains data types and classes common for all the .NET languages

· The Common Language Runtime (CLR) is similar to the Java Virtual Machine (JVM)

· C# provides support for encapsulation, inheritance, polymorphism, and interfaces

· Visual Studio provides support to VC++, Visual Basic, Vbscript, and Jscript

· .NET consists of class library and common execution engine

· Garbage collection, automatic memory management, interoperability are inbuilt in C#

· User can develop console, windows and web applications using C#

1.3 C# Environment

C# is a part of .NET framework. It is used for creating .NET applications. Using .NET framework, user can design, deploy and develop the applications. Robust applications can be easily built using the simple programming model.

Components of .NET framework

The .NET framework diagram containing several components is as shown:

The .NET framework consists of the following components:

· Common Language Runtime

· .NET framework base class library

· Common Language Specification

· User and Program interfaces

Common Language Runtime (CLR)

The core component of the .NET framework is the CLR. It is an environment where the programs are executed. The code in CLR is translated into Intermediate Language (IL). This IL code is then used across different platforms.

The IL code is converted into machine language by the Just in Time (JIT) compiler. The complier checks for the type safety. This ensures objects are accessed in a compatible way.

.NET framework class library

The class library works with any .NET languages like VB.NET, VC# and VC++.NET. The library provides classes used in the code for performing different programming tasks like data collection, string management, file access and connecting to the database.

Common Language Specification

CLR contains set of common rules used by all the programming languages in .NET framework. They are known Common Language Specification (CLS). CLS helps an object to interact with objects or applications of other languages.

User and Program Interfaces

.NET framework provides three different types of user interfaces:-

· Windows Forms: They are windows based applications.

· Web Forms: They are used for creating web based applications.

· Console Applications: They are useful for creating console based applications which are executed by the command line.