C # Type or namespace namespace "List" not found. But I import System.Collections.Generic;

I have an error

Cannot find the name or namespace name of the List. Are you missing the using directive or assembly reference?

Code example:

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 use mono if that matters.

+5
source share
3 answers

The problem arises from your instance of new List() . They also need a common 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>(); 

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

For more information and examples of creating an instance of List<T> , see the MSDN documentation.

+8
source

Replace the code as follows:

 public static List<string> items = new List<string>(); public static List<double> itemsprice = new List<double>(); public static List<double> qu = new List<double>(); 
+1
source

Try the following:

public static List<string[]> items = new List<string>();

Add brackets after the line

0
source

All Articles