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
needlestringThe 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
needleis 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
needlestringThe string to locate in the string array.
comparisonTypeStringComparisonOne 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.