Tuesday, September 13, 2011

Component Of the .net Framework


C# Tutorial - Components of the .NET Framework



The .NET Framework consists of two main components; the .NET Framework Class Library (FCL) and the Common Language Runtime (CLR). These not only allow for language independence, but also for language integration. This means that a single application may be written in more than one language through the use of assemblies.

The Common Language

InfrastructureCLR implements the international standard known as the Common Language Infrastructure (CLI). This standard has been approved by the European Computer Manufacturers Association (ECMA) and the International Standards Organization (ISO) as ISO/IEC 23271:2003 and more commonly known as Standard ECMA-335.
The CLI may be engineered into a product to run on any platform and not just windows, as with Mono and Linux by any software provider. The CLI is made up of several components:

  • Common Type System (CTS) - This provides a set of rules for defining data types that are compatible across all languages supported by the CLI. This is to allow language interoperation of assemblies at run time. Thus one data type has the same data structure and the same behaviour irrespective of which language it is used within.
  • Common Language Specification (CLS) - This is a subset of the CTS. It is a set of types that may be used in external calls in code that is intended to be portable.
  • Common Intermediate Language (CIL) - This is a set of machine instructions defined for use within the Virtual Execution System. Also referred to as managed code and managed data.
  • Metadata - This is information associated with the managed code and data that describes the data, identifies the locations of references to objects, and gives the Virtual Execution System information to handle overhead of older programming models.
  • Virtual Execution System (VES) - This is the part of the system that runs and manages .NET code at runtime in a similar manner to the Java Virtual Machine for the Java Language. The VES sits between the managed code and the native operating system.

Components of the CLI



CLI Documents

The documents are divided into five partitions:
Partition I
Detailed description of the Common Language Infrastructure concepts and architecture.
Partition II
Detailed description of the metadata: its physical layout (as a file format), its logical contents (as a set of tables and their relationships), and its semantics (as seen from a hypothetical assembler, ilasm).
Partition III
Detailed description of the Common Intermediate Language (CIL) instruction set.
Partition IV
An informative annex describing programming conventions used in defining the CLI Libraries.
Partition V
Annexes containing sample programs, information about a particular implementation of an assembler and a set of guidelines used in the design of the libraries.

A simple Calculator

// Storage
int value1 = 0;
int value2 = 0;
int total = 0;
string operation;

// Get first number
value1 = GetNumber();

// Get Operation
Console.Write("What operation would you like to perform: ");
operation = Console.ReadLine();

// Get second number
value2 = GetNumber();

// Perform the operation
if (operation == "+")
total = value1 + value2; // Addition
else if (operation == "-")
total = value1 - value2; // Subtraction
else if (operation == "/")
total = value1 / value2; // Division
else if (operation == "*")
total = value1 * value2; // Multiplication
else
{
// Ignore other keypresses
}

// Output the answer
Console.WriteLine("The total is {0}", total);

Basic Bill Creation


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bill
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;
            double q, r,b;
            Console.WriteLine("Enter  Product name");
            n = Console.ReadLine();
            Console.WriteLine("Enter Quantity");
            q = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Rate");
            r = Convert.ToInt32(Console.ReadLine());
            b = q * r;
            Console.WriteLine("Bill Amount" + b);
            Console.ReadLine();

        }
    }
}

Find out Leap Year


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace leap
{
    class Program
    {
        static void Main(string[] args)
        {
            int Year;
            Console.WriteLine("Enter the year: ");
            Year = Convert.ToInt32(Console.ReadLine());
            if ( (Year % 4 == 0) && (Year % 100 != 0) || (Year%400== 0))
            {
                Console.WriteLine("The Year you have entered is a Leap Year {0}.", Year);
            }
            else
            {
                Console.WriteLine("The Year you have entered is not a Leap Year {0}.", Year);
            }
            Console.ReadLine();
        }
    }
}

Find out Area and Parameter


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Areapar
{
    class Program
    {
        static void Main(string[] args)
        {
            float r, p, area;
            Console.WriteLine("Enter Radius");
            r = Convert.ToInt32(Console.ReadLine());
            area = 3.14f *r *r ;
            Console.WriteLine("area" + area);
            p = 2 * 3.14f * r;
            Console.WriteLine("para" + p);
            Console.ReadLine();

        }
    }
}

Name i/p infinte time


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nameinput
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,i;
            string name;
            Console.WriteLine("Enter name");
            name = Console.ReadLine();
            Console.WriteLine("Enter number for print");
            n=Convert.ToInt32(Console.ReadLine());
            i=n;
            for (i = 1; i <= n; i++)
            {
                Console.WriteLine(name);
            }
            Console.ReadLine();

        }
    }
}

Day Find


class Program
{
static void Main(string[] args)
{
int n;

Console.WriteLine("Enter any number");
n = Convert.ToInt32(Console.ReadLine());

switch (n)
{
case 0:
{

Console.WriteLine(" day is monday");
break;
}


case 1:
{
Console.WriteLine("day is tuesday");
break;
}
case 2:
{
Console.WriteLine("day is wednsday");
break;
}
case 3:
{
Console.WriteLine("day is thursday");
break;
}
case 4:
{
Console.WriteLine("day is friday");
break;
}
case 5:
{
Console.WriteLine("day is saturday");
break;
}
case 6:
{
Console.WriteLine("day is sunday");
break;
}
default:
{
Console.WriteLine("Invalid Number");
break;
}
}
Console.ReadLine();
}
}

Popular 5 Posts Last 7 days