// Enums are value types no need for using new operator
// This is prefered way of initalizing enums
Category myCategory = Category.LocationType;
myCategory = (Category)1;// or you can initailize in this way not recomended
// You can retrieve the value as int by typecasting
int catInt = (int)myCategory;
// Do the comparison as
if(myCategory == Category.LocationType)
{
// Do the operation
}
// Use ToString function to get the EnumbyName
myCategory.ToString(); // this will return LocationType
Main Topics
Browse All Topics





by: aseem_dayalPosted on 2005-09-11 at 22:19:08ID: 14861818
Hi,
ory.ToStri ng()); //this statement shall print "LocationType" on the
This is what you need to do :
Category objCategory = new Category(); //standard variable initialization
objCategory=(Category) 1; // passing an integer value to the variable, with explicit typecasting
Console.WriteLine(objCateg
//console as a string