operator for enums

Posted by Veer on Stack Overflow See other posts from Stack Overflow or by Veer
Published on 2010-03-17T07:24:30Z Indexed on 2010/03/17 7:31 UTC
Read the original article Hit count: 369

Filed under:

Hi all,

Just out of curiosity, asking this

Like the expression one below

a = (condition) ? x : y; // two outputs

why can't we have an operator for enums?

myValue = f ??? fnApple() : fnMango() : fnOrange(); // no. of outputs specified in the enum definition

instead of switch statements (eventhough refractoring is possible)

enum Fruit

Fruit f = Fruit.apple;

Or is it some kind of useless operator?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ternary-operator