Re: Custom values in Enum
- From: Bob Grommes <bob@xxxxxxxxxxxxxx>
- Date: Sat, 14 Jan 2006 11:21:13 -0700
Of course, just assign each value explicitly:
public enum Days {Sat=1,Sun=2,Mon=12,Tue=13,Wed=14}If I recall correctly the following will work too, as subsequent values are sequential:
public enum Days {Sat=1,Sun,Mon=12,Tue,Wed}This is one of those "check the docs" and/or "try it and see" kinds of issues, you could answer the question in about 60 seconds that way.
Incidentally I would not take pains to make it a byte enum unless you expect to store large amounts of the values in memory or something. Generally, ints are handled more efficiently. The only reason to use byte or short in or out of an enum is if you are going to hold a big collection or matrix of them and you want to relieve memory pressure. The system architecture is generally most efficient in terms of access speed, with ints.
Best,
--Bob
Vi wrote:
Hi,
Is there a way to declare an Enum with non-secventual values? For example I want to declare the following enum:
public enum Days :byte {Sat=1, Sun, Mon, Tue, Wed};
where Sat=1, Sun=2, Mon=12, Tue=13, Wed=14}
Is this possible? Thanks
.
- Prev by Date: passing structs through Sockets
- Next by Date: Re: passing structs through Sockets
- Previous by thread: passing structs through Sockets
- Next by thread: executing an exe located on anther computer?
- Index(es):
Relevant Pages
|
|