Remove or Trim the last character from a String

Very often during development we need to remove the last character from a string. It could be a trailing slash or a trailing comma as a result (side effect ?) of building delimited strings. There are many ways to do that in C#, however I like the following one for its simplicity and good performance:

string str = "yourstring"; str = str.substring(0, (str.length - 1));

The String.Remove method, beginning at a specified position in an existing string, removes a specified number of characters. This method assumes a zero-based index.

The following example removes ten characters from a string beginning at position five of a zero-based index of the string.

str.Remove(str.Length - 1, 1);