[問題]想回傳一個動態的class

看板C_Sharp作者 (jack)時間18年前 (2007/11/06 01:02), 編輯推噓3(303)
留言6則, 4人參與, 最新討論串1/1
如果資料庫每個表單的資料欄位都不一樣 eg Customer table Customer ID, Customer name Employee table Employee no, salary 現在我設計的是multi layer的東西 中間那一層是data access level 也就是說我的程式要 見人說人話 見鬼說鬼話 看到 customer 就 return 一個object class customer { string Customer_id; string Customer_name; } 遇到處理employee表單 就 return class employee { Employee salary; Employee no; } c#有這種功能嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.79.202.143

11/06 01:13, , 1F
傳回object, 用typeof判定類別來做相應處理
11/06 01:13, 1F

11/06 01:22, , 2F
配合object.GetType()
11/06 01:22, 2F

11/06 07:39, , 3F
這方法不可行 部份對customer是黑盒ꐠ所以ui是不知l
11/06 07:39, 3F

11/06 07:42, , 4F
customer跟employee這個type
11/06 07:42, 4F

11/06 23:50, , 5F
Reflection 是你要的東西吧
11/06 23:50, 5F

11/07 13:14, , 6F
囧 Generic可以嗎?
11/07 13:14, 6F
文章代碼(AID): #17BqoA2f (C_Sharp)