C#
  Home arrow C# arrow Page 7 - 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 - The Common Type System


    (Page 7 of 12 )

    When Microsoft designed the .NET technology, they wanted to invent a technology that would last for some time with great stability and interoperability. When you think about most programming languages,  you will find that a particular programming language consists of a set of keywords associated with a specific syntax. Attached to it are a group of data types like integer numbers, strings and floating point numbers. Most programming languages offer these data types, and most of them use the concepts of encapsulating the code into methods and, as a result, into classes.

    This is good, but because each language defines its own data types and its own syntax, it's difficult to use a component written in another language in your code, although COM gave us this feature to some extent. You could write a COM Component in Visual Basic and use it from a scripting language like VB Script, but you can't unify the way all programming languages use each others' components -- for example, you can't create a COM Component in C++ and make use of it in a Visual Basic program.

    The solution to this problem involves separating the implementation of most of the popular programming languages' data types into a unified system of syntax that can be used to operate on these data types. Microsoft has designed a Common Type System (or CTS) that defines most of the data types that have been used by most popular programming languages. The Common Type System doesn't define the syntax that programming languages use, nor does it define the keywords; it just defines the Common Data Types for all the languages that will be managed by the .NET CLR Environment.

    Different languages may use a subset of the CTS called the Common Language Specifications (or CLS) to comply with the .NET Framework (we will discuss the CLS in the next section). The most important thing that you need to understand is that the CTS doesn't define any syntax, and it's the part of the programming language to define it. I think that by now you need a definition for the CTS.

    The Common Type System: The CTS defines the rules for Types that run and can be managed by the Common Language Runtime for compilers and programming languages designers, so they can develop compilers to utilize these types and thus produce MSIL code that can be run under the CLR.

    If you ever code in C# you may ask yourself what data type to use --the ones introduced by the C# Language or the set introduced by the CTS? The answer is very simple. .NET programming languages expose their data types (that's a subset of the CTS) in their own way. For example, the CTS defines a 4-byte Type, Int32, that stores integer numbers from negative 2,147,483,648 through positive 2,147,483,647. In C# you can use the int keyword instead of the CTS official name System.Int32 to declare a variable of that type. Actually you can use any of these techniques, but for consistency it is best to use one technique throughout your code. Personally I use the C# aliases. The table below lists the CTS built-in types and their C# aliases keywords.

    DescriptionC# Keyword

    CTS Type

    The base class for all class in the .NETobjectSystem.Object
    Signed 4 bytesintSystem.Int32
    Unsigned 4 bytesuintSystem.UInt32
    Signed 2 bytesshortSystem.Int16
    unsigned 2 bytesushortSystem.UInt16
    a character string valuestringSystem.String
    Signed 1 bytebyteSystem.Byte
    Unsigned 1 bytesbyteSystem.Sbyte
    Signed 8 byteslongSystem.Int64
    Unsigned 8 bytesulongSystem.UInt64
    Two bytes Unicode charactercharSystem.Char
    four bytes floatFloatSystem.Single
    eight bytes floatdoubleSystem.Double
    sixteen bytes types exact to 29 digits. It's a requirement for banking and financial applicationsdecimalSystem.Decimal
    Boolean value, true or false boolSystem.Bolean

    A full discussion about types will have to wait until the next article. In that article, I will talk about why understanding types is critical for understanding C#. We will discuss Value Types and Reference Types and their mapping to the Common Type System. Value Types such as Built-In and Structures,  and Reference Types such as Classes, Interfaces, Delegates, Arrays and Strings will be discussed then as well.

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek