Every time that there is a new version of Visual Studio I’m very keen to learn and implement the most relevant features. The problem is that the documentation that I’ve found is too low level (i.e.: lots of details) or too light. So I decided to create a series of posts exploring  all that is new regarding VS, C# and ASP.Net while maintaining the balance between don’t say a thing and don’t say too much.

This new version of Visual Studio includes several new features and improvements. Developers will find plenty of options to develop for iOS, Android and Windows devices. Some of them are described as follows:

  • Xamarin for Visual Studio is the tool to develop/debug native apps for any device.
  • Apache Cordova with Visual Studio is the tool to build (and debug) cross-platform native applications using HTML, CSS, JavaScript and Typescript.
  • Cross-platform native development/debugging via Visual C++.
  • Cross-platform games development with Unity.
  • Universal Windows apps to target different Windows 10 devices (xBox, HoloLens, IoT, etc).
  • New compiler (Roslyn) is faster but more importantly exposes an API to analyse/generate code. Thanks to Roslyn is possible to find issues in your code as you type.
  • Other improvements in the IDE like performance tips (to check the execution time per function – you definitely will notice this new floating window!), a wizard to connect your app to backend services (incl. Azure Mobile Services, Azure Storage, Salesforce and Office 365), new breakpoint settings, graphic diagnostics for DirectX apps, edition history in CodeLens and sign-in with multiple accounts.

Say hello to C# 6!

Do you remember C# v1 back in 2002? Well, developers were presented with new language features version after version and C# 6 isn’t the exception. Off the top of my head the most important changes in C# during all these years were generics (C# 2 VS2005), automatic properties/Linq/lambda expressions (C# 3 VS2008) and async/await (C# 5 VS 2010) among others. Now for C# 6 I’m happy to describe some of the most relevant features as follows:

    • New keyword nameof to get the string name of a variable
    • String interpolation: if a picture is worth of 1000 word, a piece of code might be worth 1000’s pictures (by the way, don’t you think that the name of this feature sounds very pro?)
            // Before
            string twitterHandle = "jacace";
            System.Console.WriteLine(String.Format("My twitter handle is: {0} ", twitterHandle));
            // Now in C# 6.0
            System.Console.WriteLine($"My twitter handle is: {twitterHandle}");

    • Null conditional operator.
    • Collection initializers.
    • Exception filters:
            string str = null;
            try
            {
                Console.WriteLine(str.Length);
            } catch (NullReferenceException e) when (e.Source == nameof(Main))
            {

            }

  • Function member bodies with lambda expressions: in the following image the body of the function GetPersonalBlogUrl is defined as a lambda expression (without a return statement).

vs2015_static

  • Use of static functions as local members: as illustrated in the previous image, a static function from another class can be used locally with the using statement. This saves you two lines of code: one to import the external namespace and another one (or part of it) containing the class name.

Thanks for reading. Please remember that my descriptions and observations don’t cover every single aspect of the new features but what I think I’ll use myself. Next post will cover the .Net Framework 4.6.

Javier Andrés Cáceres Alvis

Microsoft Most Valuable Professional – MVP

Intel Black Belt Software Developer