0

I have these two line of code here

var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
        var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

And I keep getting red squiggly error underline underneath both my [] saying syntax error value expected. and I also get a red squiggly error underline underneath all my values (one, two, three, etc) but not for zero...the error is ; expected.

What Am I doing wrong?

user979331
  • 11,039
  • 73
  • 223
  • 418

3 Answers3

2

As David mentioned, you must be using a different framework which doesn't support anonymous declarations.

I just tried it using 4.5 framework and it doesn't complain.

Harish
  • 1,469
  • 16
  • 43
1

Your using an older version of C# which doesn't support the var keyword, this was introduced in v3.0 and the minimum supported version of VS is 2008.

The equivalent in your version would be:

string[] unitsMap = { "zero", "one", ... };
srring[] tensMap = { "zero", "ten", ... };
James
  • 80,725
  • 18
  • 167
  • 237
0

if "; is expected" maybe before these lines you have forgotten to end your previous line. Otherwise do a recompile. Sometimes, intellisense has to be rebooted (don't know why). Reboot VS if you will see this mistake again.