. One of the way is to use your mouse and hover over the underline and the following menu would appear, or just use Ctrl + . (Ctrl + period) and press enter as the top one which is System.Diagnostics would be automatically highlighted. This would automatically add the namespace to the top of your .cs code.
This seems to work perfectly well with Visual Studio 2008 but seems to be a bit broken with Visual Studio 2010 Beta 1. I have posted a feedback about it to Microsoft to fix it. Hope they fix it by RTM. Anyways below is the screenshots of how its done is VS2010 Beta 1. The problem is that in VS2010 beta 1 doesn’t automatically select the first item in the menu like the one VS2008 does. So, for VS2010 Beta 1 you need to use one more button – down arrow key and then enter key. This bug has already been fixed up in the internal builds of VS2010 and is expected to be in effect from the upcoming version of Visual Studio 2010.
For more articles on tips and tricks refer here. Or you can also access the page from the right menu under Page List heading.