Visual Studio 2015 Tips And Tricks

Introduction

We all have a habit of using the new version of Visual Studio as it emerges in the market. Only a few have the habit of reading about its features and also learning about the usage guidelines or tips to use for betterment.

What this article is all about?

This article will help you to know a few features and also the Tips or Tricks to use the Visual Studio which in turn make your daily activities easy and smooth.

Hope this article will be a worth reading that too consumes very less time.

Some of the Tips or Tricks:

  1. Quick Launch and Search:

    Quick launch (Qtrl+Q) is a gift that keeps on giving. You can use it to search anything you need to find in the options or in the menu.

  2. Roslyn

    Roslyn is the new, improved, open-source .NET compiler, written from the ground up exclusively in C#.

    It looks exactly the same as the editor you're used to, but offers a much better experience. A lot of modal windows have been replaced with less invasive UI analogies.

  3. Light bulb

    Light bulb - the bulb appears when the analyser has smart refactoring options and suggestions about your code When the light bulb is not available, smart refactoring can be invoked with Ctrl+.

    Inline renaming can also be invoked with Ctrl+R,Ctrl+R while the cursor lies on a specific element static using. Using this feature means that you can do away with fully qualified namespace resolution. Instead of Console.WriteLine() you can simply do this using static System.Console;
    1. WriteLine("Hi this is Bhuvan!");   
  4. Dictionary Initializers:

    The dictionaries can be initialized in a new way, as follows,
    1. static Dictionary<stringstring> GetTeachers()    
    2. {  
    3. //Older Version  
    4.     var oldStudentData = new Dictionary<stringstring>  
    5.     {  
    6.         {"Bhuvan""1001" },  
    7.         {"Prabhu""1002" }  
    8.     };  
    9.   
    10. //Newer Version  
    11.     var newStudentData  = new Dictionary<stringstring>  
    12.     {  
    13.         ["Bhuvan"] = "1001",  
    14.         ["Prabhu"] = "1002"   
    15.     };  
    16.     return newStudentData;   
  5. Null Conditional Operator:

    The operator checks to see if a referenced property is initialised and then returns the value. If the property under evaluation is not initialised, it will return null.
    1. var studAddress = student?.Address;  
  6. Selecting Block of code:

    When you want to select a complete code block very quickly. Keep you cursor either at the starting or at the ending braces, then all you have to do is Just press Ctrl + Shift + ] . You will find the complete code block is being selected.

    * Select the cursor at the starting of the block and Press Ctrl + Shift + ] the entire block is selected.

  7. ‘forr’ code snippet for reverse ‘for’ loop:

    When you type the word "forr" then, that will generate a reverse for-loop as shown below.
    1. for(int i=Length-1; i>=0; i--)  
    2. {  
    3.     //your codes...  
  8. “Shift+Enter” to add “;” semi-colon at end of the line automatically:

    You can use “Shift + Enter” to add semicolon (;) to end of the line. Instead of putting “;” end of the line, you just press “Shift+Enter”. It will automatically add “;” at the end of the line and will move the cursor to next line.

  9. Exception Filters: Here the exception can be handled with "When" in the catch block:
    1. try  
    2.     {  
    3.         throw new Exception("myError");  
    4.     }  
    5.     catch (Exception ex) when (ex.Message == "NullException")  
    6.     {  
    7.         // this is custom error, so this part will not execute.  
    8.     }  
    9.     catch (Exception ex) when (ex.Message == "Error")  
    10.     {  
    11.         // expected exception so, this will execute  
    12.         WriteLine("myError Occurred");  
    13.     }  
  10. Auto property initializer:

    This "Auto property initializer" will helps to intialize values automatically , you can initialize properties with default values, without the need for a constructor, as follows

    public string studentName { get; set; } = "Mili";

  11. Change auto-insertion of IntelliSense options as you enter code:

    To enable suggestion mode, choose the Ctrl + Alt + Spacebar keys, or, on the menu bar, choose Edit, IntelliSense, Toggle Completion Mode.

  12. Use Built-In code snippets:

    You can use built-in snippets or create your own snippets.

    To insert a snippet, on the menu bar, choose Edit, IntelliSense, and Insert Snippet or open the shortcut menu in a file and choose Insert Snippet.

  13. Bookmark lines of code:

    To set a bookmark, on the menu bar, choose Edit, Bookmarks, Toggle Bookmark. You can view all of the bookmarks for a solution in the Bookmarks window.

  14. Debugging Short Cuts:

    Activity Short Cut - Key
    Start Debugging F5
    Stop Debugging Shift+F5
    Restart Debugging Ctrl+Shift+F5
    Step Over F10
    Step Into F11
    Step Out Shift+F11
    Run To Cursor Ctrl+F10
    Set Next Statement Ctrl+Shift+F10
    Set and Toggle Breakpoint F9
    Disable Breakpoint Ctrl+F9
    Immediate Window Ctrl+Alt+I
    Immediate Window Command Mode Type “>”
    Immediate Window Clear Buffer >cls
    Immediate Window Print Value ?varname

Read more articles on Visual Studio:

Up Next
    Ebook Download
    View all
    Learn
    View all