34,333
edits
Changes
→Trimming and Padding C# Strings
System.Console.WriteLine ("[" + newString + "]"); // Outputs [ hello**********]
</pre>
== C# String Replacement ==
Parts of a string my be replaced using the ''Replace()'' method. This method takes part of the string to be replaced and the string with which it is to be replaced as arguments and returns a new string reflecting the change. The '"Replace()'' method will replace all instances of the string:
<pre>
string myString = "Hello World";
string newString;
newString = myString.Replace("Hello", "Goodbye");
System.Console.WriteLine (newString);
</pre>