Answers for "null coalescing operator c# or use iif statement"

C#
8

null coalescing operator c#

//the null coalescing operator for c# is ??
int? x = null;
int y = 9;
return x ?? y; 
//Will return the value of x if x is not null else return y
Posted by: Guest on May-06-2020
1

c# null coalescing operator

static void Sample(string input)
{
    string result = input ?? "default";
    Console.WriteLine($"Result: {result}");
}
Posted by: Guest on July-17-2021

C# Answers by Framework

Browse Popular Code Answers by Language