What does double question marks mean in C #

Possible duplicate:
What "??" operator for?

Debugging code and searching inside code. What does it mean?

+6
c #
source share
2 answers

?? - operator with zero connectivity for types with zero value.

 object obj = canBeNull ?? alternative; // equivalent to: object obj = canBeNull != null ? canBeNull : alternative; 
+16
source share

http://msdn.microsoft.com/en-us/library/ms173224.aspx refers to this description. this is an operator

Operator ?? defines the default value to be returned when a type with a null value is assigned to a type with an invalid value.

  // ?? operator example. int x = null; // y = x, unless x is null, in which case y = -1. int y = x ?? -1; // Assign i to return value of method, unless // return value is null, in which case assign // default value of int to i. int i = GetNullableInt() ?? default(int); string s = GetStringValue(); // ?? also works with reference types. // Display contents of s, unless s is null, // in which case display "Unspecified". Console.WriteLine(s ?? "Unspecified"); 
+5
source share

All Articles