The Value Types in .NET Framework. This article can also be used to prepare your self for MCTS 70-536.The article contains the
Lesson 1 Objectives of theChapter 1 of MOC 2956A : Core Foundations of .NET Framework 2.0
The objectives of this Article is to undertand
* Chosing the most efficent builtin Value Type
* Declaring Value Types
* Creating your own types
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
There are many more Value Types in the .NET Framework.
Declaring of value types are very simple
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
Nullable num=new Nullable();
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
Dim height as Integer
Dim width as Integer
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
Enum PaymentMode as Integer
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 .