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

后端 未结 7 1940
北海茫月
北海茫月 2020-12-10 01:08

I have a string

string str=\"hello\";

This is my array

string[] myarr = new string[] {\"good\",\"Hello\", \"this\" , \"new\         


        
7条回答
  •  有刺的猬
    2020-12-10 01:31

    Since you are looking for index. Try this way.

    Array.FindIndex(myarr, t => t.IndexOf(str, StringComparison.InvariantCultureIgnoreCase) >=0);
    

提交回复
热议问题