-4

I'm trying to find out if a String contains another string like this:

var s1 = "Test name*"
var s2 = "TestName"

If checked now it should return true.

7
  • 8
    s1 does not contain s2 and s2 does not contain s1 in your example, so it is unclear exactly what you are wanting from this. Commented Aug 21, 2017 at 14:25
  • Wait what? This should return true? It's either duplicate or unclear or broken! Feel free to Use the mighty Edit Button! Commented Aug 21, 2017 at 14:27
  • This search with current value of s1 and s2 will return false. Commented Aug 21, 2017 at 14:28
  • It's a duplicate question. Commented Aug 21, 2017 at 14:37
  • Are you trying to check that if both strings have whitespace removed and you are not worried about capitalization that one could be contained in the other? Commented Aug 21, 2017 at 14:40

1 Answer 1

0

Try this:

var exists = s1.Replace(" ", "").Tolower().Contains(s2.ToLower());
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.