Posted By

rtipton on 05/15/09


Tagged

null Coalescing


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

paelgr
umang_nine


Null Coalescing Operator (??)


 / Published in: C#
 

  1. using System;
  2. namespace CoalesceTst
  3. {
  4. class Program
  5. {
  6. static void Main(string[] args)
  7. {
  8. string userName = "GabrielGray";
  9. string userName2 = null;
  10.  
  11. string name = userName ?? "<no name>";
  12. string name2 = userName2 ?? "<no name>";
  13.  
  14. Console.WriteLine(name);
  15. Console.WriteLine(name2);
  16. }
  17. }
  18. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: cmichaelgraham on May 19, 2009

nice !!

You need to login to post a comment.