New in C# 6.0: Auto-Property Initializers

C# 6.0 is coming and there are a lot of exciting new features on the way.

One of these exciting new features is auto-property initializers: basically, you can set the default value of a property directly next to the property. Check it out:

public class Game
{
    public int DifficultyLevel { get; set; } = 6;
}

On top of that, we also get “getter-only” auto properties:

public class Book
{
    public string Name { get; } = "Generic Book";
}

The big win here for me is being able to initialize collections from the auto property declaration:

public class User
{
    public List<Role> Roles { get; } = new List<Role>();
}