Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Enums with multiple params!?

Status
Not open for further replies.

FOR111

Programmer
Sep 29, 2005
103
MT
Hi All,

I don;t know if this is possible; but i would like to ask if the following Enumeration is possible using c#;

public class enum MyEnum {

SUCCESSFUL_REQUEST((short) 000, "Successful request");

}

or something similar where SUCCESSFUL_REQUEST is the text with which one can view the enum, 000 is the code and the rest is the text one wishes for in the log or to be viewed by the gui!?


thanks
Nick
 
enum is a type not a class. Enum is an class.

if you want to create a enum it looks like this
Code:
public enum MyEnum : [int, byte, short, long, ...]
{
   Enum1,
   Enum2,
   Enum3
}
by default the first value starts at 1 and increments by 1 step, however you can override this by explicitly assigning a value
Code:
public enum MyEnum : int
{
   Enum1 = 4,
   Enum2 = 16,
   Enum3 = 3
}
so in your example it could look something like this
Code:
public enum Status: int
{
   Success,
   Failure,
   Pending
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top