.NET
  Home arrow .NET arrow .NET Type System, Part I
Moblin
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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? 
.NET

.NET Type System, Part I
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 44
    2005-03-08

    Table of Contents:
  • .NET Type System, Part I
  • The ILDASM.EXE Tool
  • System.Object Class
  • The Stack and the Heap
  • Structures: complex Value-Types
  • Enumerations

  • 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

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    .NET Type System, Part I


    (Page 1 of 6 )

    Learn how to write better .NET and C# applications! .NET allows you to store simple values and complex values. This article explains how, as well as how to use the ILDASM.EXE tool (Intermediate Language Disassembler) to inspect MSIL compiled .NET files. It also gives a detailed explanation of how and where the values are stored in your programs.

    In this article you will learn about Value Types and Reference Types, and when you complete the article you will have an in-depth understanding of how and where the values are stored in your programs, which will help you write better .NET and C# applications. You will learn about the Stack and the Managed Heap, too. You will use the ILDASM.EXE tool (Intermediate Language Disassembler) to inspect the MSIL compiled .NET files (which we call Assemblies). As for Value Types, you will learn about Built-In Data Types, Enumerations and Structures. As for Reference Types, you will learn about Arrays and Strings for now. There are also Classes and Delegates, but I will just introduce them here and discuss each of them in its own article. So let's get started with a look at the .NET solution for storing simple values and complex values.

    The .NET Types, again

    Every time you write C# applications you will probably be defining Types. As we discussed in the previous article, Introducing C# and the .NET Framework, a Type is a representation to a value and its associated operations, but let's try to divide the types of values that we can have in our applications.

    Every programming language has its own set of built-in data types such as integer numbers, floating point numbers and strings, and user defined data types such as classes and structures. This is great, but it's essential for you as a developer to understand what happens when you use these types, and what are the expected behaviors from each type. Say that at a given point in your application you want to store a student's total grade (which is 98) in a variable of type int (integer), so you will use the following statement:

    int TotalGrade = 98; 

    What happens here is that the CLR allocates a  four byte memory location of type System.Int32 and stores the value 98 there, and gives this location the name TotalGrade. What you need to know at this point is that:

    1. The location that the CLR has allocated to the variable TotalGrade is Strongly-Typed, which means that only the defined operations on Int32 type are permitted for this location.

    2. The TotalGrade contains a simple value which is 98 so the value is stored in the variable's memory location.

    The TotalGrade variable is a Value Type, which means that the value 98 is stored in-line (in the variable location). .NET actually defines another kind of Type called Reference Types. We will discuss Value and Reference Types in this article, but for now think of a Reference Type as a type that stores a reference to another memory location where the actual data is stored. So the .NET Type system is built on the idea of types whose variables contain the value (Value Types) and types whose variables contain a reference to another memory location where the actual value is stored (Reference Types). Table 2.1 illustrates the CTS Type System.

    Reference TypesValue Types
    1. Classes

    2. Delegates

    3. Arrays *

    4. Strings *

    5. Interfaces

    1. Primitive Types *

    2. Structures *

    3. Enumerations *

    * means that this Type will be discussed in this article, others will be discussed in later articles.

    Before we discuss Value Types and Reference Types, I want to introduce the ILDASM.EXE tool.

    More .NET Articles
    More By Michael Youssef


     

    .NET ARTICLES

    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries
    - Introducing LINQ to SQL Designer using Visua...
    - Beginning LINQ to SQL Using Visual Studio 20...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway