01 - Overview of C#

1.1 C# Introduction

C# is a type safe object oriented language that enables developers to build variety of secure and robust applications to execute on the .NET framework. User can create Windows client applications, XML web services, distributed components, client – server applications and database applications.

C# supports encapsulation, inheritance, polymorphism. C# supports pointers and unsafe code for memory access. C# supports the interoperability feature. It helps the user to perform all work similar to the C++ application.

1.2 Features of C#

The list of features of C# are as mentioned below:

1) It is used to simplify the operators and pointers used in other programming languages

2) It has dynamic lookup feature that eliminates the need to refer the type of returning objects in the assignment statement

3) Named arguments helps user to specify the method parameters by their names

4) Optional parameters are defined at the end of the parameter list after the required parameters in the list

5) It is type safe providing implicit conversions by default data type to the derived type

6) The enumeration members are placed in its scope

7) The garbage collection is automatic through the finalization process

8) The variance feature allows to specify in and out parameters on the generic types

9) The calls to the COM methods and Interop with less code in the system

10) The C# code can be compiled on various platforms

1.3 .NET Framework Architecture

The .NET framework is responsible for executing the C# program in the system. Framework is the combination of common language runtime and a set of class libraries. The implementation of Common Language Infrastructure (CLI) is done through Common Language Runtime (CLR).

Microsoft .NET framework consists of the following main components:

· Common Language Runtime

· Base class library

· User Program interfaces

The architecture diagram for .NET architecture with relationship to C# is as shown below:

Common Language Runtime (CLR): The CLR is the most important component of the .NET framework. It is an environment where all the programs using the .NET technology are executed. The services provided by CLR includes code compilation, memory allocation, and garbage collection. The code is translated into Intermediate language (IL). The IL code can be executed across different platforms.

IL is converted into machine language during the execution by Just – In – Time compiler. During the JIT compilation, the code is checked for type safety. CLR consists of common set of rules followed by all languages of the .NET framework. This set of rules is known as Common Language Specification (CLS). CLS helps the objects and applications created in certain language to interact with the object and applications of another language.

CLS has the specification defined as Common Type System (CTS). It provides a type system that is common across all languages. CTS is used to define the data types declaration, use and managed in the code at run time.

During the execution the CLR performs the following tasks:

1) Loading assemblies and identifying namespaces: Assemblies are loaded in the memory. After loading the assemblies, CLR identifies namespaces for the code in the assemblies. Namespaces are the collection of classes.

2) JIT compilation: Before the code is executed, the IL code is converted into machine language by the JIT compiler. In the verification process, the IL code is checked for memory locations available to access, methods called through the properly defined types.

3) Garbage collection: The garbage collection process executes after the JIT compilation manages the allocation and de - allocation of memory for an application.

Base Class Library: The .NET framework class library works with any .NET language such as VB.NET, VC#, VC++.NET. The class library provides classes that can be used in the code to accomplish the common programming tasks.

The .NET framework class library consists of namespaces that are contained within the assemblies.

Namespaces: The namespaces helps user to create logical groups of related classes and interfaces. It allows user to organize classes that can be used for accessing by other applications. They can be used to avoid conflicts between classes that have same names.

Assemblies: An assembly is a single deployment unit that contains all information regarding implementation of classes, structures and interfaces. The assembly holds the information about itself. The information is known as metadata.

User and Program Interfaces:

At the presentation layer, .NET provides user with three types of interfaces. They are as mentioned below:

1) Windows Forms: They are used in Windows based applications.

2) Web Forms: They are used in web applications for providing user interface. They provide user with web browser interface.

3) Console Applications: They are used to create character based console applications that are executed through command line.

The .NET framework provides interface called Web Services to communicate with remote components.

1.4 Features of .NET Framework

The list of features of the .NET framework are as mentioned below:

1) ADO.NET: It includes support for user defines types, database operations, XML data types, support for multiple active result sets.

2) .NET Remoting: It supports the exchange of generic types. It improves the performance of network load balance remote clusters.

3) XML: User can validate the DOM tree stored in an XmlDocument instance through XPathNavigator..

4) Windows Presentation Foundation (WPF): It is used for building Windows client application. It includes features like data binding, layout, 2-D and 3-D graphics, animation, styles, templates, documents, media, text.

5) Windows Communication Foundation (WCF): It is unifies programming model used for building service oriented applications.

6) Windows WorkFlow Foundation (WWF): It is used for providing a programming model, run-time engine, tools for building workflow applications.

7) Windows CardSpace (WCS): It is a digital identity to online services. It states how the user will be electronically represented.

8) Parallel Computing: It is programming model for writing multithreaded and asynchronous code simplifying the work of application developers.

9) Manage Extensibility Framework: It is a new library in the .NET framework that helps to build extensible applications.

10) Application compatibility and Deployment: The .NET framework is compatible with applications that are built with earlier versions of .NET framework.

11) Automatic resource management: The resource management for any application is done automatically done through the framework

12) Implicit conversions: The .NET framework implicitly converts the type of local variables, arrays, and other components declared in an application.

Like us on Facebook