A
A.M-SG
Hi,
Can I have enum contain strings?
Thank you,
Alan
Can I have enum contain strings?
Thank you,
Alan
Nicholas Paldino said:Alan,
As others have mentioned, no, you can not. In this situation, what I
like to do is declare an enumeration, and then apply attributes to the
values of the enumeration (after all, they are static fields) which I
retrieve at runtime to get the information I need.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
A.M-SG said:Hi,
Can I have enum contain strings?
Thank you,
Alan
apm said:Nicholas Paldino said:Alan,
As others have mentioned, no, you can not. In this situation, what I
like to do is declare an enumeration, and then apply attributes to the
values of the enumeration (after all, they are static fields) which I
retrieve at runtime to get the information I need.
Are you thinking of somethine like:
public enum Goups
{
sCH3,
etc.
}
GroupAttributes ga = new GroupAttributes (etc.)
GroupAttributes [] gaArray = new etc.
gaArray[(int)sCH3] = ga;
In words: (1) make enum (2) use enum to refer to attributes stored in an
array
???????Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
A.M-SG said:Hi,
Can I have enum contain strings?
Thank you,
Alan