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


I have to check that value 1 is "abc" inside the first x letter below . How do you check it with the if statement?

  var Value1 = "ddabcgghh"; If (value 1. Canton ("ABC")) {found = true; }  

This may occur in the first 3, 4 or 5 characters.

or if you have to determine the value:

  Found = value 1. Edit: Edit, I will do something like this:  
  found = value 1.Substring (0, 5). Contains ("abc")  

Comments