I would like to be able to:
- Check each character in a string (userInput)
- If second string contains this character, remove it from the string
Therefore: Take every character in a string and validate that these characters are all in the second string.
For example, if the second string was: "abcdefg" and the user input was "acf", the code should remove the characters "a" "c" and "f" from "abcdefg", therefore checking that all input values are valid (in the other string). This way, duplicates are accounted for.
The code I have currently:
foreach (char letter in userInput)
{
if (letters.Contains(letter))
{
//Here would be the code for removing the character from the string
Console.ReadKey();
}
else
{
Console.WriteLine("Cheater!");
Console.ReadKey();
Environment.Exit(0);
}
}
string letters = contains 7 letters string userInput = used to input letters up to 7.