The future versions are C# 6.0, .NET 4.6, Visual Studio 2015. This article talks about the great things that are coming our way.
From the official project page, Roslyn on Github: C# 6.0 Features.
From the MSDN Blog, IDE features.
C# 6.0
Null Conditional Operator
I bet you have loads of null checks in your code preceding attempts to call a method on instances. With this new operator this becomes so much easier and clean.
For example, if you have a structure like this:
- public class Sample
- {
- public Foo FooProperty { get; set; }
- }
- public class Foo
- {
- public Bar BarProperty { get; set; }
- }
- public class Bar
- {
- public void DoSomething()
- {
- Console.WriteLine("Doing something");
- }
- }
- static void Main(string[] args)
- {
- Sample nullSample = null;
- if (nullSample != null
- && nullSample.FooProperty != null
- && nullSample.FooProperty.BarProperty != null)
- {
- nullSample.FooProperty.BarProperty.DoSomething();
- }
- }
- static void Main(string[] args)
- {
- Sample nullSample = null;
- nullSample?.FooProperty?.BarProperty?.DoSomething();
- }
Sometimes you need to instantiate a class and set some default values to some of the properties, when you need that you often do it in the constructor.
- public class Sample
- {
- public Sample()
- {
- Name = "Default initial value";
- }
- public string Name { get; set; }
- }
- public class Sample
- {
- public string Name { get; set; } = "Default initial value";
- }
Not planned for the first release, but they didn't discard the idea. Primary constructors allows you to basically have a class with parameters.
- public class Sample(string name)
- {
- public string Name { get; set; } = name;
- }
The nameof expression lets you grab the name of the variable you are working with. It can be used in the NotifyPropertyChanged method, for example:
- public class Sample : INotifyPropertyChanged
- {
- private string name;
- public string Name
- {
- get { return name; }
- set
- {
- name = value;
- NotifyPropertyChanged(nameof(Name));
- }
- }
- public void NotifyPropertyChanged(string propName)
- {
- if (PropertyChanged != null)
- PropertyChanged(this,
- new PropertyChangedEventArgs(propName));
- }
- public event PropertyChangedEventHandler PropertyChanged;
- }
- public void DoSomething(object someParam)
- {
- if (someParam == null)
- {
- throw new ArgumentNullException(nameof(someParam));
- }
- //...
- }
String interpolation
You often must write:
- String.Format("hello {0}", sample.Name);
To do that you must prefix your string with the $ symbol.
- String.Format($"hello {sample.Name}");
You can define method bodies using lambdas.
- public class Sample
- {
- public string Name { get; } = "Foo";
- public override string ToString() => Name;
- }
You can choose when to catch an exception, for example:
- public void DoSomething()
- {
- bool exceptionCatchingEnabled = true;
- try
- {
- }
- catch (Exception) when (exceptionCatchingEnabled)
- {
- }
- }
Improved ToolTips
Now tooltips include colors, glyph and more information.


Code Fixes and Refactoring
Now unused namespaces are grayed out suggesting you can eliminate them.

There are more options to fix the code and you can preview the changes inline.

Removing temporary variables
Converts this:
- int val = 1 + 2;
- Sample.DoSomething(val);
- Sample.DoSomething(1 + 2);
Can inline-rename variables by pressing F2.

Window Layouts
You can customize your windows and save it. To do that go to the Window menu and select Save Window Layout, give it a name and save it. You can have multiple Window Layouts that can be loaded at anytime. The shortcut keys are Ctrl + Alt + 1, 2, 3....
More
See more at Visual Studio 2015 Preview page.

Avirup BasuPosted Jun 23, 2015, 2:20 AM
Good one.
Vipul MalhotraPosted Jun 21, 2015, 4:34 AM
Great article
Sanjay SabariyaPosted Jun 13, 2015, 6:36 AM
good one.
Miguel Angel Ruiz AlvarezPosted Jun 10, 2015, 4:36 PM
Thanks for share this new features.
Santhakumar MunuswamyPosted May 29, 2015, 3:24 AM
Thanks for good work
MichePosted May 28, 2015, 3:50 PM
Satisfactory new features.
NitinPosted May 28, 2015, 12:58 PM
nice
Manoj KulkarniPosted May 28, 2015, 5:36 AM
Nice article. Thank you for sharing
Jaipal ReddyPosted May 28, 2015, 5:11 AM
Cool
Gowtham RajamanickamPosted May 28, 2015, 3:57 AM
good one...
Atul GuptaPosted May 28, 2015, 3:56 AM
Good One
Abhishek JaiswalPosted May 28, 2015, 3:40 AM
Nice features, especially inline renaming!! :)
Kiranteja JallepalliPosted May 28, 2015, 3:25 AM
very nice
Keyur PatelPosted May 28, 2015, 2:59 AM
Good Article on C# 6 and Visual Studio 2015:-)
Manish TewatiaPosted May 28, 2015, 2:46 AM
Cool Features..! Nice Bruno
Sibeesh VenuPosted May 28, 2015, 2:17 AM
Good One.
Pankaj Kumar ChoudharyPosted May 28, 2015, 2:10 AM
Nice Article Sir..........
Mahesh ChandPosted May 28, 2015, 1:56 AM
Thanks Bruno. Inline-renaming, very cool.