LastIndexOf()

Returns the zero-based index position of the last occurrence of a specified Unicode character within this instance.

Declaration
public static int LastIndexOf(this StringBuilder sb, char character)
Example
var sb = new StringBuilder();

sb.Append("Code is like humor.");

var index = sb.LastIndexOf('.'); // 18

sb.AppendLine("When you have to explain it,");

index = sb.LastIndexOf(','); // 46

sb.Append("it’s bad.");

index = sb.LastIndexOf('’'); //51

index = sb.LastIndexOf('^'); // -1

Last updated