Five Different Ways to Get the Username in C#

Here are five different ways to get the domain and username in C#. Make sure to include System.Management, System.Security.Principal, and System.Runtime.InteropServices namespaces. Credit for Method#4 goes to Ben Reichelt and for method#5 to Nick Parker.



Visual Studio 2005 Keyboard Shortcuts

Some of the keyboard shortcuts I use for VS 2005,

  1. Ctrl K + Ctrl I [Show info about the class, method etc.]
  2. Ctrl + Shift + Space [Display parameter info]
  3. Ctrl + Space [Complete the word]
  4. Ctrl + Alt + P [Brings up the ‘Attach To Process’ dialog]
  5. Shift + F9 [Brings up the ‘QuickWatch’ dialog]
  6. Ctrl + K, Ctrl + C [Comment] and Ctrl + K, Ctrl + U [Uncomment]
  7. Ctrl + M, Ctrl + M [Toggle outlining expansion]
  8. Shift + Alt + Enter [Full screen edit mode]
  9. F12 [Goto definition]
  10. Ctrl + F12 [Goto declaration]
  11. Ctrl + Alt + L [Solution explorer]
  12. Ctrl + Shift + V [Cycle clipboard, keep pressing V to cycle]
  13. Ctrl + – [Navigate backward]
  14. Ctrl + K, Ctrl + X [Insert code snippet]
  15. Ctrl + Alt + DownArrow [Active files, then select with arrow keys]
  16. Ctrl + TAB [Cycle active files]
  17. Ctrl + L [Cut a line]
  18. Ctrl + ] [Goto matching brace]
  19. Ctrl + F3 [Find the word at cursor position]
  20. F3 [Find next going forward]
  21. Ctrl + I [Incremental search, like Firefox]
  22. Ctrl + Shift + F [Find in all files]
  23. F4 [Properties pane]
  24. Ctrl + . [Expand the refactoring help (small red/blue rectangle that shows up after an edit)]

Usually if the ‘Shift’ key is pressed during a shortcut it reverses the direction of the action. For example, Ctrl + – navigates backward, whereas Ctrl + Shift + – navigates forward. Also, F3 finds the next match going forward, while Shift + F3 finds the next match going backward.

Multi-Touch Screen

Minority Report style multi-touch screens are a reality! Very cool!