Do not confuse the static methods in the Array Class that must be used in conjunction with arrays and the instance methods of the List<T> Class.
var array = new string[] { "a", "b", ";", "," };
int i = Array.IndexOf(array, ";");
var list = new List<string> { "a", "b", ";", "," };
int j = list.IndexOf(";");
Since Array.IndexOf
is a static method, you must pass it an array as the first parameter, where as List<T>.IndexOf
is called on a List<T>
instance (i.e., on an object of that type), and therefore such a parameter is not required.
See also:
solved List.IndexOf(x) : Error => No overload for method ‘IndexOf’ takes 1 arguments in c# [closed]