Strings in C# are immutable. So you have to create a new string containing the new guessed letter. If you are new at programming: divide your code into functions that do specific tasks.
A possible solution would be the following:
using System; public class Program { public static void Main() { string answer = "Hello"; // The length of the string with stars has to be the same as the answer. string newWord = ReplaceLetter('e', "*****", answer); Console.WriteLine(newWord); // *e*** newWord = ReplaceLetter('x', newWord, answer); Console.WriteLine(newWord); // *e*** newWord = ReplaceLetter('H', newWord, answer); Console.WriteLine(newWord); // He*** newWord = ReplaceLetter('l', newWord, answer); Console.WriteLine(newWord); // Hell* } public static string ReplaceLetter(char letter, string word, string answer) { // Avoid hardcoded literals multiple times in your logic, it's better to define a constant. const char unknownChar = '*'; string result = ""; for(int i = 0; i < word.Length; i++) { // Already solved? if (word[i] != unknownChar) { result = result + word[i]; } // Player guessed right. else if (answer[i] == letter) { result = result + answer[i]; } else result = result + unknownChar; } return result; } }