C# The type or namespace name `List#39; could not be found. But I#39;m importing System.Collections.Generic;(C# 找不到类型或命名空间名称“List.但我正在导入 System.Collections.Generic;)
问题描述
我遇到了错误
找不到类型或命名空间名称列表".你失踪了吗using 指令还是程序集引用?
The type or namespace name `List' could not be found. Are you missing a using directive or an assembly reference?
示例代码:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class city1 : MonoBehaviour
{
public static List<string> items = new List ();
public static List<double> itemsprice = new List();
public static List<double> qu = new List();
}
如果重要的话,我会使用单声道.
I'm using mono if it matters.
推荐答案
问题来自您的 new List()
实例化.这些也需要通用组件:
The issue comes from your instantiation of new List()
. These also need the generic component:
public static List<string> items = new List<string>();
public static List<double> itemsprice = new List<double>();
public static List<double> qu = new List<double>();
也就是说,没有类型 List
但有一个泛型类型 List
That is, there is no type List
but there is a generic type List<T>
.
更多信息和实例化通用 List<T>
的示例可以在 MSDN 文档.
More information and examples of instantiating the generic List<T>
can be found in the MSDN documentation.
这篇关于C# 找不到类型或命名空间名称“List".但我正在导入 System.Collections.Generic;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# 找不到类型或命名空间名称“List".但我正在导入 System.Collections.Generic;


基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01