How can i count if a value, from a input box, is in an verb that’s in a string?
And if possible, give the right position of the letter in the verb (like hangman)
Also, if a verb is not containing a letter, place that letter on a list.
example with the word NAME:
- enter the letter E
- letter is in word -last position (4th)
example HELP
- Enter the letter V letter is not inside the word Add the letter to a
list (list with wrong letters)
Thanks for your help;)
Would regular expressions be a better choice? You get all the occurrences of a letter as well as if the letter does not appear at all in the string (the test is in a console application – make sure you use
System.Text.RegularExpressionsnamespace):EDIT: Included the Hangman class and a simple console call:
and the main program: