c# - correct output for enum intilization -
i declare enum
enum month { january , february , march , april , may , june , july , augest , september , octobre , november , december }
then in main prog
static void dowork() { // month first = month.january; console.writeline("first month of year : {0}", first); first++; console.writeline((int)first); }
the output on seond line should 2
but 1
what problem ( pass value issue or somthing else )
by default, first item in enum '0', each item incrementing 1
. can assign values manually, however, , should fix issue you.
note that, in case, setting first item 1
should trick, can specify value , of them:
enum month { january = 1, february , march , april , may , june , july , augest , september , octobre , november , december }
Comments
Post a Comment