Here\'s the scenario...
if (entry.Properties[\"something\"].Value != null)
attribs.something = entry.Properties[\"something\"].Value.ToString();
<
How about using an auxiliary method like this:
attribs.something = getString(
entry.Properties["something"].Value,
attribs.something);
static String getString(
Object obj,
String defaultString)
{
if (obj == null) return defaultString;
return obj.ToString();
}
Alternatively, you could use the ?? operator:
attribs.something =
(entry.Properties["something"].Value ?? attribs.something).ToString();
(note the redundant ToString() call when the value is null)