->Enum kewword is used to Declare an Enumaration
-> Enum represents a set of Named constrants(we can't change the value associated with enum)
->Enum will having an underlying types as integral type(except char) & default underlying is "int"
->Bydefault first enum is zero(0).then increase by one(1).if u start first enum is 100 its also ok.
Sample code:
public partial class Enum : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
int val=(int)Days.monday;
Response.Write(val+"<br/>");
int val1=(int)Days.tuesday;
int val2=(int)Days.wednesday;
int val3=(int)Days.thursday;
int val4=(int)Days.friday;
int val5=(int)Days.satureday;
int val6=(int)Days.sunday;
Response.Write(val1+"<br/>");
Response.Write(val2+"<br/>");
Response.Write(val3+"<br/>");
Response.Write(val4+"<br/>");
Response.Write(val5+"<br/>");
Response.Write(val6+"<br/>");
}
}
public enum Days
{
monday=100000,
tuesday,
wednesday,
thursday,
friday,
satureday,
sunday
}
No comments:
Post a Comment