dotnetspider.com Home page     All Communities

MCTS Preparation Team


The Chapter 1 :Lesson 1 for MCTS 70-536



My Profile 
  • Sign In
  •  
  • Register

  • Links 
  • Message Center
  •  
  • File Manager
  •  
  • Members
  •  
  • Hall Of Fame
  •  
  • Site Configuration





  • The Chapter 1 :Lesson 1 for MCTS 70-536


    Posted Date: 26 Aug 2009      Total Responses: 0

    Posted By: initiotech       Member Level: Silver     Points: 10


    Chapter 1: Fundamentals of .NET Framework


    Lesson 1: Using Value Types



    The objectives of this Lesson is to undertand
    * Chosing the most efficent builtin Value Type
    * Declaring Value Types
    * Creating your own types
    - Structures
    - Enumerators

    Understanding the concepts of Value Types is very simple.
    Value Types are variables that directly store the value rather than storing only
    the refernce to the value stored somewhere else in the memory.
    The Value types are Stored in a Memory Area called stack
    The stack is a memory area where the runtime can easily create,read,update and remove value quickly without any performance stress.

    All primarily numeric and Boolean values are Value Types.

    Some of the Built-In value types are
    SByte,Byte,Int16,Int32,UInt32,Int64,Single,Double,Decimal,Boolean,Char,DateTime etc..

    There are many more Value Types in the .NET Framework.
    Declaring ValueTypes
    Declaring of value types are very simple
    In C#

    // ;
    int num;

    In VB

    //Dim as
    Dim num as Integer

    Value Type Variables will never hold a Null Value.
    If you need a Value Type variable to hold a null Value we use NullableTypes

    int num?=null;
    //or
    Nullable num=new Nullable();

    In VB

    Dim num as Nullable(Of Integer)=Nothing

    Creating User-Defined Value Type
    To create a User-Defined Value Type in .NET we need to create a Structure
    As a matter of Fact Value Types like int,single,DateTime,Point are all Structures.
    To create our own Structure
    In C#

    struct Rectangle
    {
    int height;
    int width;
    }

    In VB

    Structure Rectangle
    Dim height as Integer
    Dim width as Integer
    End Structure

    One more Form of an Value Type is an Enumerator
    Enums are used to provide a list of options for developers to use in their Class.
    The Following example creates an Enum for PaymentMode
    In C#

    enum PaymentMode
    {
    Cash,
    Cheque,
    CashOnDelivery
    }

    In VB

    Enum PaymentMode as Integer
    Cash
    Cheque
    CashOnDelivery
    End Enum

    Conclusions


    Value Types are those types that store values on the Stack.
    DataTypes like int,single,float,DateTime,Point etc are Value Types
    Custom Value Types can be created using Structures
    List of Options for developers can be made by using Enumerators

    Note:If you want any assistance about other MCTS 70-536 contents PM me or join my community.

    Regards
    Hefin Dsouza




    Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Post Reply
    You must Sign In to post a response.
    Previous : Working with The BitArray Class
    Return to Discussion Forum
    Post New Message
    Category: