using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace hänga_gubbe { class Program { static void Main(string[] args) { string s = "saviosa"; char x; int counter = 0; string ut = ""; char[] bokstav = new char[7]; for (int i = 0; i < s.Length; i++) { bokstav[i] = 'X'; } do { ut = ""; Console.Write("mata in en bokstav: "); x = Convert.ToChar(Console.ReadLine()); for (int i = 0; i < s.Length; i++) { if (s[i] == x) bokstav[i] = x; } counter++; for (int i = 0; i < s.Length; i++) { ut = ut + Convert.ToString(bokstav[i]); } Console.WriteLine(ut); } while (counter < s.Length); Console.ReadKey(); } } }
for (int i = 0; i < s.Length; i++) { ut = ut + Convert.ToString(bokstav[i]); } Console.WriteLine(ut); //Add this line if (ut == s) Console.WriteLine("Congrats, you guessed right");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)