有了這個代碼:爲什麼我不能在範圍內的switch語句中使用「常量」?
public partial class Form1 : Form
{
private static readonly int TABCONTROL_BASICINFO = 0;
private static readonly int TABCONTROL_CONFIDENTIALINFO = 1;
private static readonly int TABCONTROL_ROLESANDSECURITY = 2;
private static readonly int TABCONTROL_INACTIVEINFO = 3;
. . .
int ActiveTabPage = tabControlWorker.SelectedIndex;
switch (ActiveTabPage) {
case TABCONTROL_BASICINFO:
if (currentNode == "NodeBuckingham") {
} else if (currentNode == "NodeNamath") {
} else if (currentNode == "NodeParsons") {
} else {
}
break;
...我有 「0」 代替 「TABCONTROL_BASICINFO」,或者我得到的, 「常數值 預期」
謝天Murgatroyd!它不能查看並看到TABCONTROL_BASICINFO是0嗎?
令人沮喪吧!要使用一個實際的常量而不是隻讀的靜態:( – mellodev 2012-03-22 23:08:33