使用通用型“System.Collections.Generic.List< T>”要求1类型参数通用型、参数、类型、Collections

2023-09-03 01:45:14 作者:缘中劫

这是什么意思?我用列表中的ASP.NET MVC的名单,并送他们到的ViewData ActionResuls 的检索它的观点。

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.

然而,当我将其更改为清单列表,它给了我 HttpWebException 的错误。当我检查立即窗口中,它告诉我的错误是:

However, when I change it to list of list, it gives me an error of HttpWebException. When I check it inside the immediate window, it tells me that the error is:

使用泛型类型System.Collections.Generic.List< T>'需要1类型参数

Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments

那么,这是什么意思,什么我做错使用它吗?

So, what does it mean and what did I do wrong using it?

推荐答案

名单,其中,T&GT; 类是一个泛型类型

为了使用它,你需要提供一个类型参数。

In order to use it, you need to provide a type argument.

例如,如果你想有一个整数列表,你需要声明为名单,其中,INT&GT; ,不是列表

For example, if you want to have a list of integers, you need to declare it as List<int>, not List.