Training - Beratung - Projektarbeiten

www.David-Tielke.de

Webcast C# 6.0 - Folge 1: Auto Property Initializers

Ab heute versuche ich regelmäßig Webcasts zu aktuellen Themen auf meinem YouTube-Channel zu veröffentlichen. Das Startthema werden die Neuerungen in C# 6.0 sein, welche ich in ~10 Episoden beleuchten werde.

Heute gibt es den ersten Teil zum Thema "Auto Property Initializers".


Dazu aus der Beschreibung des Roslyn-Teams:

You can now add an initializer to an auto-property, just as you can in a field:
public class Customer
{
    public string First { get; set; } = "Jane";
    public string Last { get; set; } = "Doe";
}
The initializer directly initializes the backing field; it doesn’t work through the setter of the auto-property. The initializers are executed in order as written, just as – and along with – field initializers. Just like field initializers, auto-property initializers cannot reference this – after all they are executed before the object is properly initialized.

Links:

Kommentar schreiben

Loading