We will be exploring today ‘Manipulating Strings’ in many aspects.
Escape double quotes
string myString = "This is a double quote: \".";
Accessing a specific character
StartsWith(), EndsWith(), Contains()
Check to see if a given string has a set of characters beginning , end or somewhere inside
Find the index for one string inside of another string
int myIndex = myString.IndexOf("How you are doing");
Insert: add characters starting at a given index
Remove: remove characters starting at a given index
Index, and all the way through the length you input.
Retrieve characters beginning at a given index all the way through the length you input.
Trim(), TrimStart(), TrimEnd()
Remove space characters both, or just the start or the need of the string.
Allow you specify a length for a string and a character to pad the string with if its length is less than the specified length.
myString = someValue.PadLeft(10, '#');
Notice that we are inputting a char, not a string therefore we have to use a single quote ‘no double quote
Important! Compare two strings regardless of the case. Because in C#, two strings with different cases are NOT equal.
Replace every occurance of one string with some other string.
Take a string and solit it into many strings and store them in a string array.
string names = myString.Split(';');
Concatenating strings, immutability
StringBuilder – memory efficient way of concatenating strings.