string word = "kusuma"; char c = 'u'; string newword=String.Empty; string new_string = "x"; int i = 0; do { if (word[i] == c) newword += new_string; else newword += word[i]; i++; } while (i < word.Length); Console.WriteLine(newword); Console.ReadLine();
Replace
string word = "kusuma"; char c = 'u'; string new_string = "x"; while (word.IndexOf(c) != -1) { int index = word.IndexOf(c); word = word.Remove(index, 1); // remove one char word = word.Insert(index, new_string); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)