.NET
  Home arrow .NET arrow Page 2 - .NET Type System, Part II
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? 
.NET

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

    Table of Contents:
  • .NET Type System, Part II
  • C# Classes
  • Using Arrays
  • Single-Dimension Arrays
  • Multi-Dimension Arrays
  • C# Strings
  • Boxing Operation

  • 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 II - C# Classes


    (Page 2 of 7 )

    A class in C# is much like any other class in other Object Oriented programming languages, but it's encapsulated in one file (unlike C++) with the extension .cs. Although you can write as many classes as you want in that one file, it's not a good programming practice.

    A class contains members like constructors, destructors, nested types, events, delegates, constants, indexers, properties, methods and fields. These are the members of a class, so you can define one or more of them. The expression class member refers to a piece of data or an operation that exists in the class, so methods, constructors, destructors and properties represent operations of a given class which we can call functions of the class, too.

    In C# all classes are reference types, so they need the new operator in order to be allocated on the Managed Heap. You will learn more about classes and class members in the following article.

    C# Delegates

    If you are a C++ programmer then you can think of C# delegates as function pointers (but in .NET it's type safe). A delegate is a pointer to a method in a class. We define a delegate class to declare the signature of the methods for this delegate. Windows Forms components use delegates extensively to provide the functionality of events. In order to grasp the concepts of delegates and events, you will need to look at the Generated MSIL code for these types, and this is exactly what we will do later. There is a complete, detailed article about delegates and another one about events coming later in this series, so I won't go into details here.

    C# Arrays

    C# arrays have syntax similar to Java arrays and C++ arrays, but they work differently because C# arrays have built-in methods and properties for manipulating them, which Java and C++ lack. Arrays have a base class, which is System.Array, and we will look at some of the provided methods later on the article. You can create an array of value types and reference types. We said before that Value-Types allocated on the Stack; it's true, but it needs a little explanation, since we are covering reference types in this section. 

    Arrays are reference types, so when you declare a new array that contains value types, the CLR will allocate memory space for the array elements on the Managed Heap (despite their being value types). When you begin to use the elements of the array, they will be copied to the stack. So, to put it simply, value types are declared when they're used, as we will see in an example about this later on.

    More .NET Articles
    More By Michael Youssef


     

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





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