Thursday, January 29, 2009

The Double Question Mark Operator

The double question mark operator, also called the null-coalescing operator, is one of the many new and often unknown things in .NET 2008. It is a very slick operator and very useful. Microsoft states that it


is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.


Its usage is as follows:


class NullCoalesce
    static int? GetNullableInt()
        return null;
    static string GetStringValue()
        return null;
    static void Main()
        // ?? operator example.
        int? x = null;
        // y = x, unless x is null, in which case y = -1.
        int y = x ?? -1;
        // Assign i to return value of method, unless
        // return value is null, in which case assign
        // default value of int to i.
        int i = GetNullableInt() ?? default(int);
        string s = GetStringValue();
        // ?? also works with reference types. 
        // Display contents of s, unless s is null, 
        // in which case display "Unspecified".
        Console.WriteLine(s ?? "Unspecified");

Monday, January 26, 2009

Windows Live Writer Blogging Made Easier

Recently I started to look at Windows 7 and I wanted to look at the new Microsoft Live Messenger. So when I downloaded and started to install everything I notice it asked if I wanted to install Windows Live Writer. Having looked at a number of blog posting apps and deciding that they were all lacking I was hesitant to install it. But I like to try new things before deciding if I like them or not so I let the installer rip.


To my surprise I have been more than impressed. Having worked in Microsoft Office, like many of us, I am fairly tied to the keyboard layout and hot keys, as well as I write to my blog and I like to see how my posts will look in respect to my layout and template.


The initial configuration asked me for a few details about my blog and some information for logging into it. Then it downloaded my template and articles and all kinds of stuff, all of which only took seconds, and I was ready to go. So I typed out a simple test and hit the preview tab and I was just stunned, staring me in the face was a perfect preview of my blog and my post. Perfectly rendered. Which if you know blogger their own preview tab doesn’t do that good of a job. I would think since I have a Blogger blog and not a Microsoft owned and operated one, that I would have sub par integration. But it seems to integrate better than the built in blogger one.


Another great feature is the fact that it is a rich client editor so I can do spell checking and the like with full office integration which is what I would expect.


It even has a tagging section at the bottom allowing me to pick the tags for the post from my existing set, or add a new one if I like.


One thing that is lacking is the fact that I can’t add custom tags, similar to block quote tags which are included with a simple click, I do have some custom tags for code blocks, which though it would be convenient it is no show stopper for this editor.


Anyway If you are an avid Blogger or contributor to the blogosphere I would recommend Windows Live Writer above all the other blog editors to date.

Friday, January 9, 2009

Zoom Your Desktop with ZoomIt

Recently I had to give a presentation in a room that just had an LCD screen mounted to the wall. The problem was that the screen was small for the size of the room and many people couldn't see the screen clearly and that made it fairly problematic.

After the presentation it came up that this was a problem and would continue to be a problem. And someone mentioned that many of the Microsoft presenters use a tool that zooms the entire desktop onto the mouse position. So I set out to find this tool and of course I should have know that it came out of the many great tools from Sysinternals, now part of Microsoft, written by Mark Russinovich.

The tool is called ZoomIt and now that I have it I will add it to my arsenal of great and useful tools.

It does more than just zoom, it also allows you to draw on your desktop which is great for highlighting things that you want to draw attention to. And it has a timer mode that displays a count down that you can set, for those all important breaks.