C#'s new ?? operator(blogs.sagestone.net)

submitted by bottlesbottles(420) 5 years, 10 months ago

From the post "I hadn't seen this in any of the C# 2.0 feature lists, but Fritz Onion brings this little gem to light for me. There's a new operator: ?? It's a lot like the old inline if statement."

5 comments |category: |Views: 8

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by bottlesbottles(420) 5 years, 10 months ago 0

Original post here: http://pluralsight.com/blogs/fritz/archive/2005/12/07/17313.aspx

Reply

posted by nestornestor(195) 5 years, 10 months ago 0

Nice tip, I didn't know about ?? operator. Thanks

Reply

posted by gavinjoycegavinjoyce(25.7k) 5 years, 10 months ago 0

This is news to me too, cheers.

Reply

posted by jasper22jasper22(1320) 5 years, 10 months ago 0

Ha-ha :) Let's see how you can overload and/or override this operator :)

Reply

posted by bottlesbottles(420) 5 years, 10 months ago 0

Unfortunately, you can't do something like 'object o = someStringThatMightBeNull ?? DBNull.Value'. Oh well.

Reply

information Login or create an account to comment on this story