Skip to content

String Extensions

StrutTower edited this page Nov 18, 2023 · 1 revision

String Extensions

SafeTrim()

Similar to .Trim() except that it null checks the string first. If the string is already null, it will just return null.

string name1 = "  test ";
string name1 = name1.SafeTrim();
// name1 == "test"

string name2 = null;
string name2 = name2.SafeTrim();
// name2 == null

Clone this wiki locally