如例子所示,在資料庫中儲存的是列舉型別的名稱而不是值,要如何對照呢?
首先需要進行型別轉換,列舉型別提供了parse函式,用法如下:
//刪除細目表
switch ((basetableenum)enum.parse(typeof(basetableenum), "entity.biaohao"))
case basetableenum.dc01:
dc01tablemanager dc01 = new dc01tablemanager();
ids = dc01.getids(dc01tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc01.batchdelete(ids);
break;
case basetableenum.dc02:
dc02tablemanager dc02 = new dc02tablemanager();
ids = dc02.getids(dc02tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc02.batchdelete(ids);
break;
case basetableenum.dc03:
dc03tablemanager dc03 = new dc03tablemanager();
ids = dc03.getids(dc03tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc03.batchdelete(ids);
break;
case basetableenum.dc04:
dc01tablemanager dc04 = new dc01tablemanager();
ids = dc04.getids(dc04tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc04.batchdelete(ids);
break;
case basetableenum.dc05:
dc01tablemanager dc05 = new dc01tablemanager();
ids = dc05.getids(dc05tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc05.batchdelete(ids);
break;
case basetableenum.dc06:
dc01tablemanager dc06 = new dc01tablemanager();
ids = dc06.getids(dc06tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc06.batchdelete(ids);
break;
case basetableenum.dc07:
dc07tablemanager dc07 = new dc07tablemanager();
ids = dc07.getids(dc07tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc07.batchdelete(ids);
break;
case basetableenum.dc11:
dc11tablemanager dc11 = new dc11tablemanager();
ids = dc11.getids(dc11tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc11.batchdelete(ids);
break;
case basetableenum.dc12:
dc12tablemanager dc12 = new dc12tablemanager();
ids = dc12.getids(dc12tabletable.fieldbiaobianhao, entity.id);
returnvalue = dc12.batchdelete(ids);
break;
default:
break;
C資料型別 列舉 enum 和switch語句
main.m lessoncondition created by lanouhn on 14 7 16.import 列舉型別是乙個構造型別,它使一組整型常量羅列出了有的可能性 定義列舉,使用關鍵字enum 列舉型別的名字 最後的分號不能少 列舉型別將人能夠識別的識別符和計算機能夠識別的數字對應起...
C資料型別 列舉enum 和switch語句
main.m lessoncondition created by lanouhn on 14 7 16.copyright c 2014年 vaercly 163.com 陳聰雷.all rights reserved.import 列舉型別是乙個構造型別,它使一組整型常量羅列出了有的可能性 定義...
列舉enum在switch中的用法
實際開發中,很多人可能很少用列舉型別。更多的可能使用常量的方式代替。但列舉比起常量來說,含義更清晰,更容易理解,結構上也更加緊密。列舉類 public enum democode public intgetcode public void setcode int code public string...