Method IndexOf
IndexOf(string)
Searches for the specified string and returns the index of its first occurrence in the string array.
public int IndexOf(string needle)
Parameters
needle
stringThe string to locate in the string array.
Returns
- int
The zero-based index of the first occurrence of
needle
, if found; otherwise, -1.
Exceptions
- ArgumentNullException
needle
is null.
IndexOf(string, StringComparison)
Searches for the specified string and returns the index of its first occurrence in the string array.
public int IndexOf(string needle, StringComparison comparisonType)
Parameters
needle
stringThe string to locate in the string array.
comparisonType
StringComparisonOne of the enumeration values that specifies the rules for the comparison.
Returns
- int
The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
Remarks
If needle
is null, -1 is returned.