EN
C# - The type or namespace name `List' could not be found.
1 answers
3 points
When I try to create List<int>
object, I get the following error:
xxxxxxxxxx
1
The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)
My code:
xxxxxxxxxx
1
using System;
2
3
public class Program
4
{
5
public static void Main()
6
{
7
List<int> myList = new List<int> { 1, 2, 3 };
8
}
9
}
1 answer
3 points
You forgot to import System.Collections.Generic
in your code.
Working example:
xxxxxxxxxx
1
using System;
2
using System.Collections.Generic;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
List<int> myList = new List<int> { 1, 2, 3 };
9
}
10
}
0 commentsShow commentsAdd comment