ObservableDeveloper - Leonid Sorokin's Blog

.NET, Silverlight, ASP.NET, Web Services, SQL Server, Cloud Computing, and much more...

About the author

I am a .NET Software Developer, Consultant, and Trainer from Toronto, Canada specializing in web development with Rich Internet Applications on the Microsoft development tool chain.

My Photo

Microsoft Certified Professional Developer

Null-Coalescing Operator in C#

I was reading a Silverlight related article when I stumbled on a really interesting operator. It is known as the Null-Coalescing operator, and it can be used instead of the more verbose ternary operator.

The Ternary/Conditional Operator can be used as follows:

int? currentCounter = null; // a nullable type

int counter = currentCounter != null ? currentCounter : default(int);

I also wrote code such as this many times, and at some point, you start asking yourself, isn't there a better/cleaner way? Obviously, accessing currentCounter twice is redundant.

With the Null-Coalescing Operator the above conditional operator expression can be shortened to this:

int counter = currentCounter ?? default(int);

In plain English, this would read "If currentCounter != null, then counter = currentCounter, otherwise counter = default(int)."

I think that, more than anything else, it simply results in cleaner looking code.


Categories: C#
Permalink | Comments (0) | Post RSSRSS comment feed

Live Mesh is very powerful!

I had a small issue and Live Mesh greatly helped me out.

I was actually remotely logging in and modifying this blog on another machine. However, I wanted to have a backup of the blog.

Since I was connecting remotely to work on the blog, I couldn't use a USB key and just save the blog's VS 2008 solution to it. Thus, I turned to Live Mesh.

Within about 10 minutes I was all setup and within another 10 minutes after that, the entire blog solution was synced with the cloud, and then with my local machine.

I could then open the VS 2008 locally as if I had been working on it locally all along.

You can get started with Microsoft Live Mesh Beta @ http://www.mesh.com

Powerful!


Permalink | Comments (0) | Post RSSRSS comment feed

My blog is finally on the web!

I have managed to make my blog visible on the Internet. I am using discountasp.net as my host provider, and so far, I am very pleased with them.

I plan on writing, for the most part, about Silverlight. For those of you who don't know, Silverlight is Microsoft's new RIA (Rich Internet Application) platform, and it is about to compete with Adobe Flash (Flex, AIR), Java FX, and Google Gears, just to name a few.

My own interests lie with RIA technologies, and since I am a Microsoft developer (and have been since around 1999), I will touch on other technologies only in passing and in comparison.

I plan to discuss everything about and around Microsoft Silverlight. For example, my next blog posts will deal with the following topics (in no particular order).

Silverlight + IoC (Inversion of Control)

Silverlight + Windows Azure (Cloud)

Silverlight + Control Communication (via Javascript)

Silverlight + Expression Blend

Silverlight + UI/UX

Silverlight + Security

Hopefully, you will find my posts useful and informative. I will attempt to write a post once a week, and will try to focus on quality posts only.

I am a firm believer that the age of traditional operating systems (as we know it) is coming to a timely end. RIA technologies, with Silverlight at its helm, are bound to transform the way we view the O/S and the Web Browser.

 Enjoy!


Categories: .NET
Permalink | Comments (0) | Post RSSRSS comment feed