c# - other way to check if value is null or empty and assign value -


 if (!string.isnullorempty(stringtest))            newstring = stringtest; // newstring string  else            newstring = string.empty; 

is there (simple) way achieve this?

you need null-coalescence operator:

newstring = stringtest ?? string.empty; 

Comments

Popular posts from this blog

javascript - Trigger mouseenter when an animated element touches mouse -

json - Zend error Connection -

java - Using Spring @Transactional with a combination of readOnly and write, when does this entity get committed? -