Multiple choice .net c-sharp

If an IndexofAny method is passed an array of characters it:

  1. finds the first occurrence of each letter in the string

  2. searches for the first occurrence of any of the characters in the string

  3. will search for the first occurrence of the sequence of characters

  4. generates an error

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The IndexOfAny method searches a string for the first occurrence of ANY character from a specified character array. It returns the index of the first match found, not separate searches for each character or searching for a sequence.

AI explanation

IndexOfAny takes an array of characters and returns the index of the first occurrence of any one of those characters in the string — it's an "or" search across the set, not a search for the exact sequence or every letter individually. This distinguishes it from IndexOf, which searches for one specific character or substring.