Here’s the scenario…
if (entry.Properties['something'].Value != null) attribs.something = entry.Properties['something'].Value.ToString();
While effective and working correctly, this looks ugly to me. If I don’t check for a null before performing the ToString() then it throws an exception if the property was null. Is there a better way to handle this scenario?
Much appreciated!
Update 8 years later (wow!) to cover c# 6’s null-conditional operator:
Other approaches:
I’ve also used this, which isn’t terribly clever but convenient: