csharp assign if null

Code Example - csharp assign if null

                
                        Person p;
p = p ?? new Person();
                    
                
 

null coalescing operator csharp

                        
                                //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
                            
                        
 

Related code examples