Saturday, November 29, 2008

Using enum in .net

Using a Enum in C#.net
Code Sample
// declaring a enum
enum Operations
{
add,sub,mul,div
};


public void mymethod()
{
// creating object of enum
Operations op ;

// assinging value to enum
op = Operations.add ;

// using it to compare
if(op== Operations.add)
{
// do somethng.. addition
}

}

No comments: