Changes

Jump to: navigation, search

Working with Strings in C Sharp

482 bytes added, 20:54, 23 January 2008
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>

Navigation menu