Reputation: 3559
In my *.cshtml
file, I want to have something like
@List<List<int>> exps = new List<List<int>>(){ new List<int>(){1}, new List<int>(){2}, new List<int>(){3, 4}};
(int
is to be replaced by a more sophisticated type...) When I run the page that contains the line above, I get CS0305: Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
error.
Is it possible to fix the line of code above so that it works?
Upvotes: 3
Views: 7244
Reputation: 66
The Razor engine might be getting confused. Try something like:
@{
List<List<int>> exps = new List<List<int>>(){ new List<int>(){1}, new List<int>(){2}, new List<int>(){3, 4}};
}
Upvotes: 2
Reputation: 56716
I believe this is just incorrect razor syntax. That way it should work fine:
@{
List<List<int>> exps = new List<List<int>>(){ new List<int>(){1}, new List<int>(){2}, new List<int>(){3, 4}};
}
The list then can be easily accessed over the view like this: @exps
.
Upvotes: 9