Visual Studio 15 Preview First Look & C# 7

This article explains the first look of Visual Studio 15 Preview. It will cover some important and new features and enhancements done in Visual Studio 15 such as performance, supported features of C# 7.0, Conditional Compilation Options, IDE improvements, etc.


As we know Microsoft has announced it new version of Visual studio; i.e.,  Visual Studio 15. Please do not be confused with Visual Studio 2015 (Visual Studio 14). Many developers are getting confused with Visual 2015 so I am going to clarify the difference so that you can understand it easily. Visual Studio 2015 is a product name having the version number Visual Studio 14 and here I am talking about Visual Studio 15;  that product name may be announced as Visual Studio 2016 or Visual Studio 2017. To understand it more clearly have a look at the below screenshot.


  1. Up to 30 percent faster than Visual Studio 2015

    As per Microsoft, Visual Studio ‘15’ starts at 30 percent faster than Visual Studio 2015, but it varies from PC to PC and when I tested it at my end then the result was very different. On my laptop, Visual Studio ‘15’ took only 3 seconds to start whereas Visual Studio 15 took 10 seconds to start. I installed Visual Studio 2015 6-7 month ago and I was unhappy witthe  start time of Visual Studio 2015 and I think Microsoft has taken this issue seriously andare doing start time improvements in an upcoming version.


  2. Using Local Functions or Nested Functions (Feature of C# 7)in Visual Studio Preview

    Using local functions inside a function is called local function. Even though C# 7 has not been announced officially, some features are being added with C# which developer communities are saying is C# 7. To understand how local function works just have a look atthe below code and see how you are going to write and call Add() and Multiply() methods.
    1. usingstatic System.Console;  
    2. namespace UseLocalFunctions  
    3. {  
    4.     classProgram  
    5.     {  
    6.         staticvoid Main(string[] args)  
    7.         {  
    9.             void Add(int x, int y)  
    10.             {  
    11.                 WriteLine($ "Sum of {x} and {y} is : {x + y}");  
    12.             }  
    14.             void Multiply(int x, int y)   
    15.             {  
    16.                 WriteLine($ "Multiply of {x} and {y} is : {x * y}");  
    17.                 Add(30, 10);  
    18.             }  
    19.             Add(20, 50);  
    20.             Multiply(20, 50);  
    21.         }  
    22.     }  
    23. }  


If you are not aware about C# 6.0 features and you are wondering how WriteLine() method is used without Console and what is $ “” then please visit the below links for details,

  1. Using Static Classes as Directive in C# 6
  2. C# 6.0 String Interpolation

    But when I tried to run the same code inside Visual Studio 2015 SP1 then I got a lot exceptions and warning. Please have a look at the below screenshot which displays the build error in Visual Studio 2015.


  3. Using Binary Literal

    Inthe new version of C# we can use binary literals in the same way as hexadecimal literals are used.

    C# supports Hexadecimal literas and we use 0x or 0X and now C# will support binary literals too and we will use 0b and 0B for binary literals.
    1. usingstatic System.Console;  
    2. namespace VisualStudio15FirstLook   
    3. {  
    4.     classProgram   
    5.     {  
    6.         staticvoid Main(string[] args)  
    7.         {#region Using Binary Literal  
    8.             int x = 0b1010000; //binary value of 80  
    9.             int SeventyFive = 0B1001011; //binary value of 75  
    10.             WriteLine($ " {x} \n {SeventyFive}");#endregion  
    13.             # region Using Hexadecimal Literal  
    14.             int a = 0x50; //Hexadecimal Value of 80  
    15.             int b = 0X4B; //Hexadecimal value of 75  
    16.             WriteLine($ " {a} \n {b}");#endregion  
    18.         }  
    19.     }  
    20. }  
    As stated earlier hexadecimal literalis already supported in C# and if you run the same code inside Visual Studio 2015 then you will get error for binary literal but hexadecimal literals are compiled successfully. Refer to the below screenshot for the build error being displayed for the same code with Visual Studio 2015.


  4. Using Digit Separators

    Digit separator is also a new feature in C# which is supported with Visual Studio ‘15’ preview. We can use one or more than one Underscore( _ ) character for digit separators, so the code snippet would look something like:
    1. #region Using Digit Separators  
    2. int binaryData = 0B0010_0111_0001_0000; // binary value of 10000  
    3. int hexaDecimalData = 0X2B-67; //HexaDecimal Value of 11,111  
    4. int decimalData = 104_567_789;  
    5. int myCustomData = 1___________2__________3___4____5_____6;  
    6. double realdata = 1_000.111_1e-1_000;  
    7. WriteLine($" binaryData :{binaryData} \n hexaDecimalData: {hexaDecimalData} \n decimalData: {decimalData} \n myCustomData: {myCustomData} \n realdata: {realdata}");  
    8. #endregion  
    This feature will work only with Visual Studio ‘15’ preview and not with VS 2015.

  5. Pattern matching
    1. //Example 1  
    2. var myData = "Custom Data";  
    3. var myData2 = myData isstring ? "aaaaa":"bbbbbb";  
    4. var myData3 = myData isstring a ? a : "Not a String";  
    6. WriteLine(myData2);  
    7. WriteLine(myData3);  
    9. //Example 2  
    11. var x = 10;  
    12. var y = 0b1001;  
    13. var z = y isint ? $"{y * x}" : "Invalid data";  
    15. WriteLine(z);  
    Apart from this we can use a lot of other types of pattern matchings like Type Pattern, Constant Pattern, Var Pattern, Recursive Pattern, Property Pattern& Property Sub-pattern, Switch Statement, Match Expression, Case expression, Throw expression, Destructuring assignment,Testing Nullable, Arithmetic simplification, Tuple decomposition, Complex Pattern,Wildcard Pattern etc.

  6. Custom Code Style Enforcement (C# Code Style Preferences)

    The Custom Code Style Enforcement option provides us the feature to add some preferences. It has three sections of preferences,

    a. ‘this.’ preferences,
    b. predefined type preferences
    c. var preferences

    You can open this window by navigating to Tools > Options > Text Editors > C# > Code Style,


  7. Execute in Interactive (Execute your Code Snippet Inside C# Interactive Window)

    Now you can execute a code snippet very easily using C# interactive window to do this you just need to select the code snippet and press “Ctrl+E,Ctrl+E”


    or you can use context menu for it. Select the code snippet and right click on it.


  8. New compiler flags: two new compiler flags have been added deterministic&publicSign.

  9. ref returns and Ref Locals.

  10. Add Conditions to Exception Settings

    in Visual Studio ‘15’ preview we can add conditions for break and thrown exceptions and we can set  how to handle this if it is coming from a   particular module.

    Suppose FileNotFound exception occurs from PDFConversion.dll then we can se whether  that application should break or not etc.

  11. Open Folder (New Feature in Visual Studio 15 Preview)


    Apart from this in Visual Studio ‘15’ preview you can open and edit any code from any folder.

  12. Edit & Continue for XAML apps (WPF & Universal Windows App):

    In Visual Studio ‘15’ preview we can edit XAML while application is running and new code change will be reflected immediately i.e. we do not need to recompile the application.

    Here I have focused only on Visual Studio IDE and C# new features but this is not a complete list and Microsoft has added lot of new features for Apache Cordova, Visual C++, Team Explorer, SSDT, Nuget, Application Insights& JavaScript.
Read more articles on Visual Studio:


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now