indexOf Case Sensitive?

后端 未结 19 1230
日久生厌
日久生厌 2020-11-27 19:39

Is the indexOf(String) method case sensitive? If so, is there a case insensitive version of it?

19条回答
  •  离开以前
    2020-11-27 19:49

     static string Search(string factMessage, string b)
            {
    
                int index = factMessage.IndexOf(b, StringComparison.CurrentCultureIgnoreCase);
                string line = null;
                int i = index;
                if (i == -1)
                { return "not matched"; }
                else
                {
                    while (factMessage[i] != ' ')
                    {
                        line = line + factMessage[i];
                        i++;
                    }
    
                    return line;
                }
    
            }
    

提交回复
热议问题