Is there Better way to check if a string is empty or null using Null Coalescing operator .When I use empty value to a string instead of null the null Coalescing operator failed to get me the desired result.
string x = null;
string y = x ?? "Default Value";
Console.WriteLine(y);
Here if I replace x = null with x="" this doesnt work.
If I use String.IsNullOrEmpty method
if(String.IsNullOrEmpty(x)
{
y= "default value"
}
{
y =x
}
My code block is having multiple lines and I want to make it simple. Can you suggest a better way to keep the code clean and simple. As it is used in many places.