C#
  Home arrow C# arrow Page 3 - Introducing C# and the .NET Framework
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Introducing C# and the .NET Framework
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 87
    2005-01-31

    Table of Contents:
  • Introducing C# and the .NET Framework
  • The .NET Framework
  • C# Source code
  • The .NET Type Story
  • A World of .NET
  • The Common Language Runtime
  • The Common Type System
  • A World of Interoperability Through the CLS
  • Where Can I Find the .NET SDK?
  • Writing the Hello World Example with the C# Compiler
  • Assemblies
  • Analyzing the Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introducing C# and the .NET Framework - C# Source code


    (Page 3 of 12 )

       

    When you write an Application in C# the compiler doesn't generate a binary file (like traditional compilers) but rather it generates a file (for now you can call this file a .NET Module) that contains Microsoft Intermediate Language (MSIL) code,  plus metadata (which we will discuss in the article on the Assemblies). So if you use Visual Basic.NET, the VB.NET compiler will generate MSIL, too -- and this is also the case for Managed C++ or any other .NET compliant language (more about .NET Compliant Languages later).

    The Common Language Runtime (which is the execution environment for the .NET Framework Applications) has a compiler called Just-In-Time, or the JIT Compiler, which will compile the MSIL Instructions into native CPU Instructions upon the first execution of your application methods on a one-by-one basis. I think this needs a little more explanation.

    When you write a C# application that contains only two methods, such as the following class:

    class Class1
    {
        static void Main(string[] args)
            {
                Console.WriteLine("Hello World");
                Console.WriteLine("I like C# Programming");
            }
    }

    then, when you compile this code, the C# Compiler will generate a file that contains the MSIL of the application. When you execute this application the Common Language Runtime will compile the MSIL Instructions into native CPU Instructions using the JIT Compiler on the first invocation for each method in your program.

    So for the first call to Console.WriteLine("Hello World"); method will call the JIT Compiler to compile it to native CPU and save this native CPU version of the method to a block of memory, so the next call to this method will call this memory version, which guarantees fast performance.

    The next statement calls the same method (Console.WriteLine()) with a different argument, so this will call the native CPU in-memory version of the method and pass it the string "I Like C# Programming." Note that when you terminate the execution of your application the in-memory version of your methods will not be available (it will be destroyed) and it will be created each time you execute your application. So the process is repeated every time you execute your application.

    You may think that this two step compilation may slow the performance of your applications, but you should know that Microsoft spent a lot of time on optimizing this process. Before .NET, when you compiled an application, the compiler optimized the code but it optimized this code on the machine that you used to compile the application. So when you installed or deployed the application on your client machines, it would simply run but it would not be optimized. With the .NET Framework and the Common language Runtime, the application is compiled to MSIL Instructions, and when you run the application the JIT Compiler will optimize it depending on the current platform. So when you use, for example, a computer with a Pentium 4 processor, the JIT Compiler will know and actually optimize to this processor's features.

    More C# Articles
    More By Michael Youssef


     

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek