using System;
using System.Text;
class StringManipulation
{
static void Main()
{
string s = "Hello";
Console.WriteLine("Original String: " + s);
s = s.ToUpper();
Console.WriteLine("Uppercase: " + s);
s = s.Replace("HELLO", "WORLD");
Console.WriteLine("Replaced: " + s);
// StringBuilder
StringBuilder sb = new StringBuilder("Welcome");
sb.Append(" to C#");
Console.WriteLine("StringBuilder Append: " + sb);
sb.Insert(0, "Hi! ");
Console.WriteLine("After Insert: " + sb);
sb.Replace("C#", "Programming");
Console.WriteLine("After Replace: " + sb);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter