Replace char inside a string : String Replace « Data Types « C# / C Sharp






Replace char inside a string

    

using System;

public class TestStringsApp {
    public static void Main(string[] args) {
        string a = "strong";

        // Replace all 'o' with 'i'
        string b = a.Replace('o', 'i');
        Console.WriteLine(b);

        string c = b.Insert(3, "engthen");
        string d = c.ToUpper();
        Console.WriteLine(d);
    }
}

   
    
    
  








Related examples in the same category

1.use the Insert(), Remove(), and Replace() methods to modify strings
2.String reverse and replaceString reverse and replace
3.Inserting, replacing, and removingInserting, replacing, and removing
4.String insert and outputString insert and output
5.remove any of a set of chars from a given string.
6.Replaces the specified string to replace.
7.Replace Once
8.Replaces the new lines in a string with the given replacement characters.