In C# 6 you can have the following property:
public Uri MyProperty => new Uri();
Or you can have this:
public Uri MyProperty1 { get; } = new Uri();
Whats the difference between them?
In C# 6 you can have the following property:
public Uri MyProperty => new Uri();
Or you can have this:
public Uri MyProperty1 { get; } = new Uri();
Whats the difference between them?
The first returns a new Uri
object each time you access the property - the second initializes the property to a new Uri
object and gives the same object every time.
The difference is that this will create a new instance of Uri
every time:
public Uri MyProperty => new Uri();
And this will work with backing field with assigned value:
public Uri MyProperty1 { get; } = new Uri();