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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -