Я собираю все расширенные функции для этого, но не очень много работал с обобщениями или лямбда-выражениями:
Вот пример использования метода, который я хочу создать:
MyClass mc = null;
int x = mc.TryGetOrDefault(z => z.This.That.TheOther); // z is a reference to mc
// the code has not failed at this point and the value of x is 0 (int's default)
// had mc and all of the properties expressed in the lambda expression been initialized
// x would be equal to mc.This.That.TheOther's value
Вот, насколько я понял, но я не уверен, что делать с этим объектом выражения.
[ 1