Good morning all!
VS2010
.NET 3.5
Here is a snippet in VB.Net that works, but the C# version does not.
VB.Net:
The C# code:Code:Dim a(8) As String Dim b As String Dim c As Short a(0) = "There" a(1) = "Not Here" a(2) = "Over Here" b = "Not Here" Select Case b Case a(0) c = 1 Case a(1) c = 2 Case a(2) c = 3 End Select
The Case a[x]: is the problem.
I'm getting an error: "A constant value is expected".
Can anyone help?Code:string a = new string[8]; string b; int c; a[0] = "There"; a[1] = "Not Here"; a[2] = "Over Here"; b = "Not Here"; switch (b) { case a[0]: c = 1; break; case a[1]: c = 2; break; case a[2]: c = 3; break; }




Reply With Quote