mardi 7 avril 2020

check if a string contains letters from another string

I'm working on a "Create name function". The new name that should be created can't be the same name that already exists. I have a string usernames; that contains all the already existing names like that: Tom bob Harry... and then i have an input field where you can write the new name. string newName = inputField.text

I want to do an if statement that looks if the newName cointains a name from the string usernames. I have already tried this:

if (usernames.Contains(NewName)) //if the newName not already exists

But here was the problem that every newName don't contained the usernames even if it did. I've searched for hours but i'm pretty new to this and couldn't find a good answer. I'm thankful for any help! :)

Aucun commentaire:

Enregistrer un commentaire