Is there an easier way to do this in C#? (null-coalescing type question) -


is there easier way this?

string s = i["property"] != null ? "none" : i["property"].tostring(); 

notice difference between , null-coalesce (??) not-null value (first operand of ?? op) accessed before returning.

try following

string s = (i["property"] ?? "none").tostring(); 

Comments