程序中有名為accountType的AccountTypes?,F(xiàn)在想當(dāng)accountType時(shí)savings的時(shí)候執(zhí)行一種命令,Chequing的時(shí)候執(zhí)行另一種,Investment的時(shí)候執(zhí)行第三種,所以想用switch來完成,但是Case那里不知道寫什么
1 回答
青春有我
TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超8個(gè)贊
enum AccountTypes { Savings, Chequing, Investment };
AccountTypes oneType;
.....
switch (oneType)
{
case AccountTypes.Savings:
....
break;
case AccountTypes.Chequing:
....
break;
case AccountTypes.Investment:
....
break;
default:
break;
}
添加回答
舉報(bào)
0/150
提交
取消
