Re: enums ... what am I doing wrong?
From: Hans Kesting (news.2.hansdk_at_spamgourmet.com)
Date: 11/11/04
- Next message: Jon Skeet [C# MVP]: "Re: how to pass in empty value for array argument?"
- Previous message: Miha Markic [MVP C#]: "Re: SQL Parameters using the IN keyword"
- In reply to: Craig: "enums ... what am I doing wrong?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 11 Nov 2004 10:21:59 +0100
Craig wrote:
> Newbie...
>
> I'm casting enums back and forth to ints so to use them as an index
> into a complex two dimensional array. I thought it would help
> readability. Instead, my code has casts all over the place.
>
> All the casting is giving me the jitters. Where did I go wrong?
>
> Thanks!
How about using constants instead of enum values?
* same readability of enum (words instead of "magic numbers")
* they really are int's
public const int WHATEVER = 3;
myval = store[WHATEVER];
Hans Kesting
- Next message: Jon Skeet [C# MVP]: "Re: how to pass in empty value for array argument?"
- Previous message: Miha Markic [MVP C#]: "Re: SQL Parameters using the IN keyword"
- In reply to: Craig: "enums ... what am I doing wrong?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|