I’ve been reading the Visual Studio 2015 releasenotes (https://www.visualstudio.com/en-us/news/vs2015-vs.aspx) and while I am waiting for the ASP.Net vNext, here are some things which I find are nice improvements:
Nameof provides a refactoring-safe way of getting the name of e.g. a parameter, member or type as a string.
Finally a typesafe way of referencing the name of a variable!
and here is the new code:
No more referencing the wrong variable name when the refactoring missed the “variabele name by string”!
From the docs: “An interpolated string expression looks like a template string that contains expressions. An interpolated string expression creates a string by replacing the contained expressions with the ToString represenations of the expressions’ results.”
Here’s an example:
Code with string interpolation
And the compiler checks the expressions in the string text!
Copied from here (https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6) which contains a good explanation:
Sometimes code tends to drown a bit in null-checking. The null-conditional operator lets you access members and elements only when the receiver is not-null, providing a null result otherwise:
int? length = customers?.Length; // null if customers is null
Customer first = customers?; // null if customers is null
The null-conditional operator is conveniently used together with the null coalescing operator ?? :
int length = customers?.Length ?? 0; // 0 if customers is null
The null-conditional operator exhibits short-circuiting behavior, where an immediately following chain of member accesses, element accesses and invocations will only be executed if the original receiver was not null:
int? first = customers?.Orders.Count();
This example is essentially equivalent to:
int? first = (customers != null) ? customers.Orders.Count() : null;
Except that customers is only evaluated once.
Lambda Expressions in Debugger Windows
You can now use lambda expressions in the Watch, Immediate, and other debugger windows in C# and Visual Basic.
Lambda expressions are used so frequently that this feature is highly welcomed during debugging sessions!
JSON Editor Improvements
Un-minify context menu. You can right-click the JSON editor and select Un-minify context menu to un-minify any long arrays in the JSON file.
Tooling support for AngularJS. Now, when you are writing apps using AngularJS, IntelliSense provides suggestions for Angular controllers, services, factories, directives, and animations.