Re:New Features in C# 7.0
by louthy on Thursday March 09, 2017 @11:59PM
(#13836504)
> here's nothing preventing the method call from mutating it.
There is, the class could be immutable.
public class Vector
{
public readonly int X;
public readonly int Y;
public Vector(int x, int y)
{
X = x;
Y = y;
}
public Vector With(int? X = null, int? Y = null) =>
new Vector(X ?? this.X, Y ?? this.Y);
}
I believe record-types are proposed for the next release of C#.
There is, the class could be immutable.
I believe record-types are proposed for the next release of C#.