Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts

Tuesday, June 30, 2009

Creating A Shortcut To Open Current File In Explorer From Visual Studio

Here's a neat little item that most people won't know about in Visual Studio 2008 - opening the directory of the current file in windows explorer:

Friday, March 13, 2009

Tips 'n' Tricks - Null Coalescing Operator

We all like the null coalescing operator (http://msdn.microsoft.com/en-us/library/ms173224.aspx), but it’s frustrating when we need to set the variable we’re returning rather than just returning it.

Really we just want to do this:

public class Something
{
private string falafel;

public string GetInfo()
{
return falafel ?? "tabbouleh";
}
}

But then falafel doesn’t get set.

This feels inelegant:

if (falafel == null)
falafel = "tabbouleh";
return falafel;

Luckily, there’s a solution:

return falafel ?? (falafel = "tabbouleh");

This first sets the value of falafel and then returns it.