我有错误
类型或命名空间名称`List'无法找到。你错过了吗 using指令或汇编引用?
示例代码:
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();
}
如果重要的话我会使用单声道。
答案 0 :(得分:8)
问题来自您new List()
的实例化。这些还需要通用组件:
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>
。
可以在MSDN documentation中找到有关实例化通用List<T>
的更多信息和示例。
答案 1 :(得分:1)
用以下代码替换您的代码:
public static List<string> items = new List<string>();
public static List<double> itemsprice = new List<double>();
public static List<double> qu = new List<double>();
答案 2 :(得分:0)
试试这个:
public static List<string[]> items = new List<string>();
在字符串
后添加括号