why do we prefer ? to ?? operator in c#?

Viewed 43157

I recently found that we can use ?? operator to check nulls. Please check the below code samples:

   var res = data ?? new data();

This is exactly similar to

   var res = (data==null) ? new data() : data ;

I checked my whole project source repository and some of other open source projects. And this ?? operator never been used.

I just wondering is there any reason behind this, like performance problems or something?

EDIT:

I just updated my sample code based on the comments from recursive & Anton. Its a mistake in careless. :(

7 Answers
Related