This project has moved. For the latest updates, please go here.

MvvmLight & C#6

Jul 29, 2015 at 9:45 AM
With the introduction of Visual Studio 2015 we also get some now C# 6 features. I was playing around with this to improve my viewmodels and run into some issues/questions

1. Set & nameof() operator
What is preferred:
Set(() => MyProperty, ref _myProperty, value);
Set(nameof(MyProperty, ref _myProperty, value);
2. ICommand & Auto-property initializers/Expression-bodied function members
Auto-property initializers
public ICommand MyCommand { get; } = new RelayCommand(DoSomething);
This does not work because DoSomething needs to be a static member

Expression-bodied function members
public ICommand MyCommand => new RelayCommand(DoSomething);
This works, but then every time the MyCommand property is called\bind a new instance of a relaycommand is created. Is this an issue?

I would like to get some other opinions