Click here to Skip to main content
15,879,535 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Walk 'object tree' with easy null handling

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
19 Dec 2010CPOL 4.5K   1  
Looks good!I would suggest using Func instead of GetDelegate, simply because it's the same thing.Also, the compiler will deduce the type for you, so there's no need to write:Level3 level3 = NullHelper.Get(() => level1.Level2.Level3);when:var level3 = NullHelper.Get(()...
Looks good!

I would suggest using Func<T> instead of GetDelegate<T>, simply because it's the same thing.

Also, the compiler will deduce the type for you, so there's no need to write:
Level3 level3 = NullHelper.Get<Level3>(() => level1.Level2.Level3);

when:
var level3 = NullHelper.Get(() => level1.Level2.Level3);

may be easier to read.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Undead Labs
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --