user225626
user225626

Reputation: 1099

Error thrown on List initialization

Why would this yield a 'Method name expected' error? (The part under new List[10] is squiggly underlined.)

List<int>[] whatever = new List<int>[10]();

Upvotes: 1

Views: 99

Answers (1)

Yuriy Faktorovich
Yuriy Faktorovich

Reputation: 68737

List<int>[] whatever = new List<int>[10];

The syntax for initializing an array doesn't need parentheses. If you're trying to initialize a List with a starting capacity of 10, use:

List<int> whatever = new List<int>(10);

Upvotes: 7

Related Questions