?? in C#, or the null coalescing operator basically checks to see if a value is null and if so returns an alternate value.
if (x == null)
{
x = "No Value";
}
else
{
x = "Name";
}
can be condensed to:
x = "Name" ?? "No Value";
Â
?? in C#, or the null coalescing operator basically checks to see if a value is null and if so returns an alternate value.
if (x == null)
{
x = "No Value";
}
else
{
x = "Name";
}
can be condensed to:
x = "Name" ?? "No Value";
Â