layris3 / Daily-learning-experience-record

daily learning experience
0 stars 0 forks source link

c#-null-coalescing operator?? #3

Open layris3 opened 4 years ago

layris3 commented 4 years ago

the null-coalescing operator defines a default value for a nullable type; for example, void SampleMethod(int? x) { int y; y = x ?? 1; }

the expression y = x ?? 1;means return the value of x if it has value,or return 1 if x is null