Con questo codice:Perché non posso utilizzare una "costante" all'interno di un'istruzione switch all'interno dell'ambito?
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;
... devo sostituire "TABCONTROL_BASICINFO" con "0", o ricevo, "Un valore costante è previsto"
Cieli a Murgatroyd! Non è possibile cercare e vedere che TABCONTROL_BASICINFO è 0?
Frustrante eh! Devi usare una const effettiva piuttosto che la statica di sola lettura :( – mellodev