.NET
  Home arrow .NET arrow Page 3 - .NET Type System, Part I
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 
Mobile Linux 
App Generation ROI 
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


    .NET Type System, Part I - System.Object Class


    (Page 3 of 6 )

    The CTS has a base class, System.Object, that all other classes in the .NET Framework must derive directly or indirectly. At first you may think that it's not useful, but think about it: traditional programming languages has primitive types to store integers, floating point numbers and character strings besides the user defined data types in the form of classes. In these programming languages, the lack of a common base class for all other classes caused a lot of problems. In traditional languages built-in types have nothing in common, so you can write general purpose code (unlike C# and .NET Complaint Languages). In C# we can write code this way:

    public void GetName(System.Object anyType)
    {
      Console.WriteLine(anyType.ToString());
    }

    This method accepts a paramter of type System.Object and calls the method ToString() on that Type. We can't do this in the same way in C or C++ and we will have to write wrapper classes and overload constructors for each type we want to support. The CTS comes to the rescue with its base class (System.Object); all objects derive from it, and this includes value types and reference types of built-in and use-defined types. The following are the public and protected methods of this class, which are implicitly inherited by any class.

    Public methods

    Method

    Description

    ToStringThis method returns a string to represent the object; it's like an answer for the question "What's your name?". It is virtual, which means that derived classes override it to supply an appropriate name for the object. For example, the Customer class may override this method to return the following pattern: CustomerFirstName + CustomerLastName;
    EqualsThis method behavior differs from value types and reference types. We will talk about this method in the last article (Objects manipulation and Operations). For now it is enough to say that it compares two objects and return true if they are equal and false if they are not.
    GetTypeThis method returns a string that represents the Type of the object.
    GetHashCodeCall this method on the object to retrieve a hash code that can be used in hash tables for faster performance.

    Protected methods

    FinalizeThe CLR calls this method before garbage collection operates. This method is used for clean up and release operations of resources that has been used by your object. It's not guaranteed that the CLR will call this method, so you need to use another technique to release the resources.
    MemberWiseCloneIt's a shallow copy of the object. More on Copying objects later.

     

    More .NET Articles
    More By Michael Youssef


     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - 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





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT