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

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

json - Zend error Connection -

javascript - Trigger mouseenter when an animated element touches mouse -