Static Field: String.Empty (zero-length string “”)

Readonly indexer

[] operator can be used for readonly access to individual characters of a string:

string str = "test";  
char x = str[2];  // x = 's'; 

Verbatim string

Use @"c:\Docs\Source\a.txt" rather than "c:\\Docs\\Source\\a.txt"

Empty check

String.IsNullOrEmpty(String); // static method
String.IsNullOrWhiteSpace(String); // static method

Split

Split (instance method)

public string[] Split(T[] separator, StringSplitOptions options)

/*
T : Char, String                
T[] separator : if null or empty => white-space characters are assumed to be the delimiters                
Enum StringSplitOptions: None/RemoveEmptyEntries            
StringSplitOptions.None : returned array will contain String.Empty ("") elements        
StringSplitOptions.RemoveEmptyEntries : returned array will not contain String.Empty ("") elements    
*/

Regex.Split (static and instance method)

var substrings = Regex.Split(input, pattern);

Regex regex = new Regex("-"); // Split on hyphens
var substrings = regex.Split("plum--pear");

/*
The Regex.Split methods are similar to the String.Split(Char[]) method, 
except that Regex.Split splits the string at a delimiter determined by a regular expression instead of a set of characters.
*/

Join (static method)

String.Join<T>(String, IEnumerable<T>);
String.Join<T>(String,  Enumerable.Where<T>(lambda));

/*
If separator is null, an empty string (String.Empty) is used instead. 
If any member of values is null, an empty string is used instead.
*/

Substring (instance method)

Substring(startIndex); // up to end
Substring(startIndex, endIndex);

Replace ( instance method)

string.Replace(Char, Char);
string.Replace(String, String);

// static and instance methods
Regex.Replace(string[], pattern, replaceWith);  // Regex.Replace(arr, @",", String.Empty);
Regex.Replace(overloads);  

Trim (instance method)

Trim()        // Removes all leading and trailing white-space characters
Trim(Char[])  // Removes all leading and trailing occurrences of a set of characters 

String Method Details

Conversion to array

string to array

var array = str.Split(string[] separator, StringSplitOptions options)

// separator is null or "" => deault (white-space characters) will be used
// StringSplitOptions.None >> returned array contains both empty and non-empty items
// StringSplitOptions.StringSplitOptions.RemoveEmptyEntries >> returned array contains only non-empty items

array to string

var str = String.Join(string separator, params string[] value);
var str = String.Join(string separator, IEnumerable<T> values);
// there are other overloads

Conversion to list

string to list

List<string> words = myString.Split(delimiters, StringSplitOptions.RemoveEmptyEntries).ToList();
// T[] delimiters , T == Char, string
List<string> words = myString.Split(" ").ToList()

list to string

string combindedString = String.Join(" ", list)

Conversion to dictionary

string to dictionary

var dict = text.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries)
               .Select(part => part.Split('='))
               .ToDictionary(split => split[0], split => split[1]);

dictionary to string

string str = string.Join(";", myDict.Select(kv => kv.Key + "=" + kv.Value).ToArray());

Binary digits

string binaryString = Convert.ToString(n, 2); // "110011010111"
int value = Convert.ToInt32("11001", 2)