Common String Methods

var mySeries = new string('*', 10);

var testString = "My String...";
Console.WriteLine(testString.StartsWith("My"));
Console.WriteLine(testString.EndsWith("My"));
Console.WriteLine(testString.EndsWith("My"));

Console.WriteLine(testString.IndexOf("...", StringComparison.InvariantCultureIgnoreCase));
Console.WriteLine(testString.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase));
Console.WriteLine(testString.IndexOfAny(new[] {'S', 'r'}));
Console.WriteLine(testString.LastIndexOfAny(new[] {'y', 'g'}));

Console.WriteLine(testString.PadLeft(20, '+'));
Console.WriteLine(testString.PadRight(20, '+'));

Console.WriteLine(testString.Substring(3, 6));

Console.WriteLine(testString.Remove(5));
Console.WriteLine(testString.Remove(3, 2));

Console.WriteLine(testString.Replace("My", "Your"));

Console.WriteLine(testString.TrimStart());
Console.WriteLine(testString.TrimEnd());
Console.WriteLine(testString.Trim());

var newString1 = testString.Insert(testString.Length, "New Value");
var newString2 = string.Join(" | ", "Value 1", "New Value 2");
var stringArray = newString2.Split(" | ", StringSplitOptions.RemoveEmptyEntries);

foreach (var c in testString)
{
    Console.WriteLine(char.IsDigit(c));
    Console.WriteLine(char.IsLetter(c));
    Console.WriteLine(char.GetNumericValue(c));
    Console.WriteLine(char.IsControl(c));
    Console.WriteLine(char.IsSurrogate(c));
    Console.WriteLine(char.IsUpper(c));
    Console.WriteLine(char.IsLower(c));
    Console.WriteLine(char.IsPunctuation(c));
    Console.WriteLine(char.IsSymbol(c));
    Console.WriteLine(char.IsWhiteSpace(c));
    Console.WriteLine(char.IsSeparator(c));
}

byte[] bytes = Convert.FromBase64String(textString);
string str = Convert.ToBase64String(bytes);

Best Practices for Using Strings in .NET

String Intern Pool

Character Encoding

Compare Strings

string.Equals()

var areEqual = string.Equals("Equality", "equity", StringComparison.InvariantCultureIgnoreCase);

string.Compare()