[英]Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
What does it mean? 这是什么意思? I used a list of list in ASP.NET MVC and sent them through
ViewData
of ActionResuls
to retrieve it in views. 我在ASP.NET MVC中使用了一个列表列表,并通过
ActionResuls
ViewData
发送它们以在视图中检索它。
However, when I change it to list of list, it gives me an error of HttpWebException
. 但是,当我将其更改为列表列表时,它会给我一个
HttpWebException
错误。 When I check it inside the immediate window, it tells me that the error is: 当我在即时窗口内检查它时,它告诉我错误是:
Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
使用泛型类型'System.Collections.Generic.List <T>'需要1个类型参数
So, what does it mean and what did I do wrong using it? 那么,它是什么意思,我用它做错了什么?
The List<T>
class is a generic type. List<T>
类是泛型类型。
In order to use it, you need to provide a type argument. 要使用它,您需要提供一个类型参数。
For example, if you want to have a list of integers, you need to declare it as List<int>
, not List
. 例如,如果要获得整数列表,则需要将其声明为
List<int>
,而不是List
。
I guess you wrote something like List<List>> ...
我猜你写了类似
List<List>> ...
东西List<List>> ...
But there is no class named List.. - List has a generic type parameter. 但是没有名为List的类。 - List有一个泛型类型参数。
For example - list of lists of integers should be 例如 - 整数列表应该是
List<List<int>> listOfLists = .....
For better understanding of C# generics take a look here . 为了更好地理解C#泛型,请看这里 。
I was able to just use using System.Collections.Generic;
我只能使用
using System.Collections.Generic;
to get access to lists. 访问列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.