I can't seem to figure out why I keep getting this error.

No overload for method IndexOf takes '1' arguments

Here's the code and error:

1

Best Answer


Array.IndexOf is a static method, meaning you call it on the Array class itself instead of an instance, so the proper syntax would be:

int ender = Array.IndexOf(inList, ";")

It's interesting that the compiler tries to bind it to Array.IndexOf and does not find a static method with only one argument, hence the error message. The real problem would have been clearer if you had used the correct number of arguments, in which case you'd get the message

Member 'System.Array.IndexOf<T>(T[], T)' cannot be accessed with an instance reference; qualify it with a type name instead