问题
I'm new to C# comming from a python background. I'm currently trying to solve this challenge on codewars.com. It's about finding all the divisors to a number. I tried programming the following way
public class Kata
{
public static int[] Divisors(int n)
{
List<int> divisors = new List<int>();
int i = 2, biggest_divisor = n;
while (true)
{
if ( n % i == 0)
{
divisors.add(i);
divisors.add(n/i);
biggest_divisor = i;
}
if ( i > biggest_divisor)
break;
i++;
}
return divisors;
}
}
I get this error however
error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
I looked at other questions refering to this error aswell but that didn't solve my problem. For instance I tried declaring the list as public static
.
来源:https://stackoverflow.com/questions/60391439/getting-error-cs0246-the-type-or-namespace-name-list-could-not-be-found-w