How to determine if string contains specific substring within the first X characters

前端 未结 10 1606
一生所求
一生所求 2020-12-08 09:06

I want to check whether Value1 below contains \"abc\" within the first X characters. How would you check this with an if statement?



        
10条回答
  •  星月不相逢
    2020-12-08 10:09

    I would use one of the of the overloads of the IndexOf method

    bool found = Value1.IndexOf("abc", 0, 7) != -1;
    

提交回复
热议问题