{
Mr, Mrs, Miss
// Mr=5, Mrs, Miss=2
};
//IN the above case int value will be 0,1,2
//And in commented peace of code value will be 5,6,2
/*The enum type must be byte, sbyte, short,ushort, int, uint, long, or ulong.
**********
* if we will not give the type it will take bydefault as Int
* e.g
enum Tasks:long
{
Mr=500,
Mrs,
Miss
};
**********
*/
class Program
{
static void Main(string[] args)
{
//============================Value Type Classification================================
//1. Built in Type: e.g int16,int32,decimal,system.char,double,boolean,datetime etc.
//2. User Defined Types: Structure
//3. Enums
//Note: 1> All value type stores in stack it takes small memory
// 2> Uint32 for all positive whole numbers
// 3> String() is a method derived from Syste.object all value types are derived from the same base class.
//============example on built in Value Types===========================
// Nullable
//OR
b = true;
//Has value checks for nullability
if (b.HasValue)
{
Console.WriteLine("B has Proper Value i.e {0} ", b);
}
else
{
Console.WriteLine("B is having Null Value");
}
//=========================Enumerations Example===================
Tasks tsk = Task.Mr;
Console.WriteLine("B has Proper Value i.e {0} ", tsk.ToString());
//O/p: Mr
Console.WriteLine("B has Proper Value i.e {0} ", i);
//O/P: 1
Console.Read();
}
}
No comments:
Post a Comment