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

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

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

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -