Friday, October 06, 2006

With all the other language goodness we got in C# 2.0, the new ?? operator seems to have been completely overshadowed.  Those familiar with some other languages' boolean operators (like JavaScript or Ruby) that work with their notion of conditional expressions to provide a "short-circuit" operation that returns the value of the first choice that returns something "true".  C# has a more strict notion of boolean values, so cannot re-use it's boolean operators for such an operation.  But, now we have ??, which accomplishes just about the same thing for practical purposes.

?? returns the first operand that is not null.  Like || and &&, it is a short-circuit operator, so when you string it together it only evaluates until it reaches something not null.  While not as powerful as what JavaScript and Ruby provide (because types aren't dynamic), it can still simplify your code.

So, for instance if you were ever trying to provide a default output for "null" values, you could do something like:

string defaultOutput = "[Not provided]";
Console.WriteLine(name ?? defaultOutput);
Console.WriteLine(email ?? defaultOutput);

This is a simple application, but it can be used in lots of different ways, you can string it together to provide lots of different fallbacks.  It even works correctly with Nullable<T>!

How this was included without me knowing about it is a mystery. So, you might be thinking that I learned this from some internal source here at Microsoft.  Nope.  Miguel blogged about it, and had the same "how didn't I already know this" reaction that I did.

posted on Friday, October 06, 2006 8:16:10 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Thursday, October 05, 2006

Dad bundled up on a ski trip several years ago. Yup, it's that time of the year again, my dad's birthday.  This is his first birthday as a grandfather.  He's been incredibly supportive of our move even though its taken his granddaughter so far away, so I've tried really hard to keep he and mom "plugged in" with lots of video chats and such.

Here's a humorous picture of him all bundled up on a ski trip several years ago.

Thanks for always being so supportive, Dad.  I hope you have a wonderful day.

posted on Thursday, October 05, 2006 7:35:33 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Tuesday, October 03, 2006

I was walking down the halls today, and noticed a discarded bookshelf.  Since I didn't have one in my office, I thought it would make a nice addition.  I thought I should make sure it was up for grabs, so I poked my head into the nearest office and asked, "Hey, so do you know what's up with this bookshelf?"

Then, my eye caught the nameplate, and I realized that I was talking to none other than Lutz Roeder himself, creator of Reflector and other cool tools. At that point, having not prepared myself for such a meeting, I geeked out.  I don't exactly remember what I said or did after that, but I'm sure it wasn't pretty.

So, now I have Lutz's old bookshelf in my office.

[UPDATED] Added picture.

posted on Tuesday, October 03, 2006 1:21:14 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Sunday, October 01, 2006

I just upgraded my blog to dasBlog 1.9.  It has some great new features including having multiple "contributors", so who knows, maybe Becky will do a post now and again.  Let me know if something is amiss, and I'll deal with it.  Thanks Scott, Omar and team for what looks like a great release.

[UPDATE] Well, I seem to have clobbered my links and blogroll during the upgrade.  I have them backed up, but they were badly in need of updating anyway.  I'll try to get those back and updated soon.  Right now, I'm going to bed.

posted on Sunday, October 01, 2006 8:59:11 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]
 Saturday, September 30, 2006

Woodland Park Zoo set. Becky, Jenna and I went to the zoo today.  The Woodland Park Zoo to be exact.  It was a very nice zoo, with a great variety of animals, fairly good habitats, and not so big that you feel like you have to rush through it. Jenna really liked the penguins. I'd write more about it, but I'm pretty tired.  Enjoy the photoset.

posted on Saturday, September 30, 2006 9:04:57 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, September 28, 2006

I just got an email saying that the September CTP for Orcas (That is, the next Visual Studio-centric release of what most people think of as ".NET") was just released publicly!  Go get it!  It's packaged as a Virtual PC image, so you need that or virtual server to run it, but I think that's a great deployment vehicle for these CTPs that are traditionally "difficult" to uninstall due to the nature of them being "early".

This release has some of the C# 3.0 support as well as some of the LINQ support (over objects) as well as lots of other goodies like the managed add-in model and some timezone goodness.  Unfortunately, most of these bits were baked before I got here, but it's cool to see them ship anyway.  Have fun.

posted on Thursday, September 28, 2006 7:27:14 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, September 26, 2006

Everyone run over and vote for my suggestion of adding APIs for webcam support in the XNA framework.  Do it now! Even if you don't know what I'm talking about!  Ha ha.

Seriously though, I think that would be sweet, and would make homegrown games that much better.

UPDATE: OK, evidently, you must first go to the Microsoft connect homepage and sign-in/register with a Windows Live ID/MS Passport account.  Then, the link above will work.  That's kind of frustrating.  Sorry.

posted on Tuesday, September 26, 2006 5:55:22 PM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
 Monday, September 25, 2006

Wow, lots of posts materializing today.

This is just a short one. Thanks to a suggestion from a friend, I now can receive mail at Microsoft from the marklio alias! So, put marklio together with microsoft dot com, and I'll get it!  No need to attempt to remember my other weird alias that I discussed earlier.

Basically, I just created a global distribution list called marklio and put myself in it.  Simple, eh?

posted on Monday, September 25, 2006 2:42:28 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

New house set This is somewhat old news to some of you, but due to the nature of the process, I delayed making an announcement in this public place.  But, now that all the ducks are in a row, we're marching toward closing within the next 3 weeks on a house here in the Seattle area.

Becky and I are super-excited about it.  We were really worried we would have to settle for something that we didn't really like due to the crazy housing market here, as well as the deadlines surrounding our relocation benefits.  But, we were able to jump on what we feel is a fantastic place for us to be.  I've chosen several of the exterior shots to make public in the set, since most of the interior shots contain the previous owner's things.  And, since I like them so much, most of the shots are panoramas.

posted on Monday, September 25, 2006 1:46:40 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

I just got "direct to Flickr" functionality working on my phone through a small utility that runs on Windows Mobile 5.  Now, when I take a picture, it immediately and transparently sends it to Flickr.  The camera on my phone is now actually useful without jumping through alot of hoops. Yeah.  Here's a picture of the drink I am currently drinking.

posted on Monday, September 25, 2006 1:18:05 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]
 Sunday, September 24, 2006

I've got lots of other posts in the works, but this one's a quickie.  I finally got ahold of the camera for the 360.  In just seconds, I had a video chat going with my brother.  For families that are far apart, buying a 360 just might be worth it just because it's so dang easy to set up video chat.

What was more surprising is that I plugged it into my PC, and just as quickly, it was set up as a webcam.  That was lucky for me because my fairly new logitech webcam seems to be having some driver issues with the latest build of Windows Vista.

One drawback is that there is no built-in mic, which gets a little annoying if you trying to show someone that Jenna can say "apple", "meow-meow", "ma-ma", and "da-da" on command.

Another drawback is that there is no fullscreen, or even large screen option.  Hopefully that will be rememdied with a software release.  Or perhaps I can write a video chat program with XNA express.  Oooh, that's a good idea.  I hope the APIs support that.

posted on Sunday, September 24, 2006 7:36:08 PM (Pacific Standard Time, UTC-08:00)  #    Comments [3]