My Snippets

Converting an int to an enum value


enum Status
{
   New = 0,
   InProgress = 1,
   OnHold = 2,
   Completed = 3,
   Cancelled = 4
}

Status status1 = (Status)Enum.Parse(typeof(Status),"InProgress");
Status status2 = (Status)Enum.ToObject(typeof(Status), 1);

February 24th, 2010 Posted by | c# | no comments

No Comments

No comments yet.

Sorry, the comment form is closed at this time.