G
Guest
I realize that C# is a strongly typed language, but as a C++ programmer converting to C# I find the requirement that I typecast my integer enum values to be particularly annoying. Does anyone else in the C# community think that the compiler should relax this a bit
// example, define an enum that derives from an int type
public enum Fruit : in
Apple = 1
Banana = 2
Cherry = 3
Date = 4
// etc..
// later in my code I want to use the fruit enum to index some arrays
stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] )
// I have already told the compiler in my enum declaration that a Fruit is an integer, so why
// do I have to do it this way
stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] - shipped[ (int) Fruit.Apple ] )
// just seems like a lot of unnecessary typing to me...
Sorry to gripe, but this is one place I can post it where somebody who can actually do something about it might see it :-
-- Steve
// example, define an enum that derives from an int type
public enum Fruit : in
Apple = 1
Banana = 2
Cherry = 3
Date = 4
// etc..
// later in my code I want to use the fruit enum to index some arrays
stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] )
// I have already told the compiler in my enum declaration that a Fruit is an integer, so why
// do I have to do it this way
stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] - shipped[ (int) Fruit.Apple ] )
// just seems like a lot of unnecessary typing to me...
Sorry to gripe, but this is one place I can post it where somebody who can actually do something about it might see it :-
-- Steve