System.Collections.Generic.List<T> requires '1' type arguments

c#, list

Solution

You are trying to create a `List<string>` and you should tell that to the compiler

var list = new List<string>(colors);

There is no `List`, there is a generic class named `List<T>`, requires a type parameter.You can't create a generic list without specifying the type parameter.

Also you are trying to call `Count` extension method.That method takes `IEnumerable<T>` as first parameter,not `IEnumerable`, here is the definition:

public static int Count<TSource>(this IEnumerable<TSource> source)

so you should use `IEnumerable<string>` to access that extension method:

IEnumerable<string> query = list.Where(c => c.Length == 3);
list.Remove("red");
Console.WriteLine(query.Count());

Problem

I have this error whith the following code: ``` string[] colors = { "green", "brown", "blue", "red" }; var list = new List(colors); IEnumerable query = list.Where(c => c.length == 3); list.Remove("red"); Console.WriteLine(query.Count()); ``` Moreover, `Count()` does not seem to be allowed anymore. Is it deprecated?

Original source

Related problems