Saturday, December 18, 2010

Visual Studio Keyboard Shortcuts


Visual Studio has over 450 keyboard shortcuts. The most useful of which are listed below. The keyboard shortcuts are categorized by the Visual Studio activity:
Switching between Windows within Visual Studio:
  • Ctrl+F6 – switch between the panes   in the  main code editing window.
  • Shift+Alt+Enter – full-screen mode toggle.
  • Alt+F6/Alt +Shift+F6 – move cursor from the main editing window to the   docked windows such as  Properties, Help,   Server Explorer  etc.
  • F7 – Move to the Code Behind editing page.
Editing:




  • Ctrl+Shift+V – cycle through the items saved onto the clipboard ring.
  • Ctrl+- (Ctrl + Hyphen) – navigate between pages (as in Internet Explorer). Use Shift Ctrl+- to move in the opposite direction
  • Block Selection: – hit Alt and then select the highlight the area.
  • Line No in Code – Tools>Options>Text Editor>All Languages>General>Line numbers.
  • F4: Property Window
  • Ctrl+Alt+L – Open and show the Solution Explorer
  • Ctrl+Alt+O – Open and show the Visual Studio Output Window
  • Ctrl+Alt+K – Show the Task List
  • Ctrl+Shift+Space – show the intellisense window.
  • Ctrl+R – Word Wrap toggle on/off
BookMarking:

  • Ctrl+K, Ctrl+K – Create or Remove a Bookmark
  • Ctrl+K, Ctrl+N – Move to the next bookmark
  • Ctrl+K, Ctrl+P – Move to the previous bookmark
  • Ctrl+K, Ctrl+L – Clear all the bookmarks on the page.
Code Formatting:

  • Ctrl+K, Ctrl+F – Auto-format the highlighted selection
  • Ctrl+U – Convert the selection to lower case
  • Ctrl+Shift+U – Convert the selection to upper case
  • Ctrl+K, Ctrl+C – Comment the highlighted selection
  • Ctrl+K, Ctrl+U – Uncomment the highlighted selection
Running/Debugging:

  • F5 – Start running the App in debug Mode
  • Ctrl+F5 – Start the app without debugging
  • F11 – Step into (ie moves cursor to the next executed line of code)
  • F10 – Step over (ie moves cursor to the next executed line of code in the current process and skips stepping into lines of code in functions called by the current process).
  • Shift + F11 – Step Out.
  • Shift + F5 – Quit debugging.
  • Ctrl+Shift+F5 – Restart Debugging.

Visual Studio Debugging Tutorial – Basics


If there’s a single feature of Visual Studio that every developer uses and is essential to the development process it is the built-in debugger.
Debugging can be commenced by clicking the green arrow button in the VS toolbar, selecting Debug-Strart Debugging from the menu, or hitting F5. Before commencing debugging you will need to select what exactly you are debugging, just starting debugging will commence the project from the default point. For a Web Forms app, if you want to start from another page other the default start page right click the page and select Set As Start Page. For a Win Forms app set the start Form in the application properties window first.
Prior to debugging, it will almost always be necessary to to set some breakpoints. Breakpoints pause the execution of the code and allow developers to examine controls and variables before allowing the program to continue to execute. Set a breakpoint by clicking in the margin of the code editor to and a red ball with code highlighted will appear (as shown below). The program’s execution will now be halted immediately before the highlighted line of code is hit.
ScreenHunter 01 Feb. 11 15.31 Visual Studio Debugging Tutorial   Basics
So if we now hit F5 and start debugging there should be a delay as the project is built and the code will then be highlighted in yellow with a yellow arrow at the left:
ScreenHunter 02 Feb. 11 15.42 Visual Studio Debugging Tutorial   Basics
At this point we can view variable values by hovering over them. Hovering over the vsTutor variable shows a value of 0 , hovering over the i variable does not work as the highlighted line as not been executed and the i variable not instantiated.
There are a number of important windows to monitor objects as the code executes, these are located in the bottom left by default but if not visible they can be opened from Debug>Windows.
The Watch window allow monitoring of any object which can simply be highlighted in the code window and dragged to the Watch window. The Watch window monitor objects regardless of whether they are in scope or now.
The Locals window cannot have objects dragged into it and shows all objects that are currently in scope. A powerful feature of the locals window is that it allow the objects to by modified. In this example, the value of the vsTutor variable can be modified by clicking and changing the number in the Value column.
The Autos window shows the objects used in the execution of the current statement.
The Immediate window allows for statements to be written and executed as the program’s execution is paused.
The Breakpoints window allows the breakpoints for the project to be managed by enabling, disabling or deleting them.
At all times the yellow arrow shows the line of code that will be executed next. This arrow can be dragged down to execute subsequent lines of code without executing the code that it is dragged over.
When in debug mode the Debug toolbar will either appear in the main tool bar of Visual Studio or a floating toolbar as show below.
ScreenHunter 04 Feb. 11 16.09 Visual Studio Debugging Tutorial   Basics
The three buttons to the right of the yellow arrow are crucial to the debug process:
Step Into executes the next line of code that the program would normally execute.
Step Over proceeds to the next line of code in the current procedure, this means that other routines (such as functions) are called it will not proceed into those routines but simply execute them and continue to the next line of the current code block.
Step Out will move to the line of code which called the current process or the next breakpoint if that comes first.
In the next Debugging Tutorial we will proceed to examine more advanced Visual Studio debugging topics.

Visual Studio Debugging Tutorial – Basics


If there’s a single feature of Visual Studio that every developer uses and is essential to the development process it is the built-in debugger.




Debugging can be commenced by clicking the green arrow button in the VS toolbar, selecting Debug-Strart Debugging from the menu, or hitting F5. Before commencing debugging you will need to select what exactly you are debugging, just starting debugging will commence the project from the default point. For a Web Forms app, if you want to start from another page other the default start page right click the page and select Set As Start Page. For a Win Forms app set the start Form in the application properties window first.



Prior to debugging, it will almost always be necessary to to set some breakpoints. Breakpoints pause the execution of the code and allow developers to examine controls and variables before allowing the program to continue to execute. Set a breakpoint by clicking in the margin of the code editor to and a red ball with code highlighted will appear (as shown below). The program’s execution will now be halted immediately before the highlighted line of code is hit.



ScreenHunter 01 Feb. 11 15.31 Visual Studio Debugging Tutorial Basics



So if we now hit F5 and start debugging there should be a delay as the project is built and the code will then be highlighted in yellow with a yellow arrow at the left:

ScreenHunter 02 Feb. 11 15.42 Visual Studio Debugging Tutorial Basics



At this point we can view variable values by hovering over them. Hovering over the vsTutor variable shows a value of 0 , hovering over the i variable does not work as the highlighted line as not been executed and the i variable not instantiated.



There are a number of important windows to monitor objects as the code executes, these are located in the bottom left by default but if not visible they can be opened from Debug>Windows.

The Watch window allow monitoring of any object which can simply be highlighted in the code window and dragged to the Watch window. The Watch window monitor objects regardless of whether they are in scope or now.

The Locals window cannot have objects dragged into it and shows all objects that are currently in scope. A powerful feature of the locals window is that it allow the objects to by modified. In this example, the value of the vsTutor variable can be modified by clicking and changing the number in the Value column.

The Autos window shows the objects used in the execution of the current statement.

The Immediate window allows for statements to be written and executed as the program’s execution is paused.

The Breakpoints window allows the breakpoints for the project to be managed by enabling, disabling or deleting them.



At all times the yellow arrow shows the line of code that will be executed next. This arrow can be dragged down to execute subsequent lines of code without executing the code that it is dragged over.



When in debug mode the Debug toolbar will either appear in the main tool bar of Visual Studio or a floating toolbar as show below.



ScreenHunter 04 Feb. 11 16.09 Visual Studio Debugging Tutorial Basics



The three buttons to the right of the yellow arrow are crucial to the debug process:

Step Into executes the next line of code that the program would normally execute.

Step Over proceeds to the next line of code in the current procedure, this means that other routines (such as functions) are called it will not proceed into those routines but simply execute them and continue to the next line of the current code block.

Step Out will move to the line of code which called the current process or the next breakpoint if that comes first.

In the next Debugging Tutorial we will proceed to examine more advanced Visual Studio debugging topics.

Friday, December 17, 2010


The C# FAQ—Frequently Asked Questions—provides answers to the most common questions asked of our C# and .NET community.

Contents

[hide]

C# Frequently Asked Questions (FAQ)

The C# Language FAQ

C# and .NET FAQ

C# and C FAQ

C# and C++ FAQ

C# and Java Language FAQ

C# and Visual Basic (VB) FAQ

C# and Visual J++ FAQ

C# and ADO.NET FAQ

C# and Windows Forms FAQ

See also

C# FAQ—Frequently Asked Questions


The C# FAQ—Frequently Asked Questions—provides answers to the most common questions asked of our C# and .NET community.

Contents

[hide]

C# Frequently Asked Questions (FAQ)

The C# Language FAQ

C# and .NET FAQ

C# and C FAQ

C# and C++ FAQ

C# and Java Language FAQ

C# and Visual Basic (VB) FAQ

C# and Visual J++ FAQ

C# and ADO.NET FAQ

C# and Windows Forms FAQ

See also

LinkWithin

LinkWithin

Like Us On Facebook and Receive All Updates!

You can also receive Free Email Updates:

Powered By Tutorails