Answers for "String.Replace() c#"

C#
14

c sharp string replace

// You can use the function 'Replace()' to replace all instances
// of a string or character with a given string or character.
str  = "Hello World!"
str.Replace('o', 'e');
// Output: "Helle Werld!"
Posted by: Guest on February-26-2020
2

String.Replace() c#

String s = "aaa";
Console.WriteLine($"The initial string: {s}");
s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d");
Console.WriteLine($"Final String: {s}");

// Returns "Final String: ddd"
Posted by: Guest on February-10-2021

C# Answers by Framework

Browse Popular Code Answers by Language