How to add a case-insensitive option to Array.IndexOf

Beaware !! The Answer marked might have some problem , like

string array[] = {"hello", "hi", "bye" , "welcome" , "hell"}

if you use the same method as described in the answer to find the index of word “hell”

Int Indexofary = Array.FindIndex(array, t => t.IndexOf("hell", StringComparison.InvariantCultureIgnoreCase) >=0);

you will get result Indexofary = 0 instead of 4.

Instead of that use

Array.FindIndex(array, t => t.Equals("hell", StringComparison.InvariantCultureIgnoreCase));

to get proper result .

Rrgards
Bits

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)