本文介绍了C#找不到类型或名称空间名称“列表".但是我要导入System.Collections.Generic;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到错误

示例代码:

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<T>.

That is, there is no type List but there is a generic type List<T>.

可以在.

这篇关于C#找不到类型或名称空间名称“列表".但是我要导入System.Collections.Generic;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 02:51