請問
C# 的 case 後面得接字串(string)或數值(int)
我現在有一個 controlList
我要抓 controlList上每個物件的型別(就是判斷是 textbox 或是 radiobutton)
有什麼型別轉換的方法可以去抓到值?
還是一定得用 if else寫
第二個問題 enum 可以放在 foreach 裡面嗎?
還是有什麼特殊的寫法?
以下程式碼他會出現錯誤
我在想 o.getType 可以轉換成字串嗎 @@
foreach (object o in controlList)
{
switch(o.getType)
{
case TextBox:
(敘述)
break;
case DropDownList:
(敘述)
break;
case RadioButton:
(敘述)
break;
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.76.87
→
01/02 22:06, , 1F
01/02 22:06, 1F