Skip to content

Object Extensions

StrutTower edited this page Nov 18, 2023 · 4 revisions

Object Extensions

TrimProperties()

Detects any string properties on the object and runs the SafeTrim() function on them. Does not run recursively.

Person person = new() {
    FirstName = " John ",
    LastName = "Smith   "
};

person.TrimProperties();

// person.FirstName == "John"
// person.LastName == "Smith"

IsGenericList()

Check if the object is a List<> without checking the generic type of the list

List<Person> people = new();
bool isList = people.IsGenericList();
// returns true;

string testString = "Test String;
bool isList = testString.IsGenericList();
// returns false;

Clone this wiki locally