The short =>
syntax for defining member functions and read-only properties was introduced in Expression bodied members C# 6.0.
C# 7.0 expands this support to constructors, finalizers, get accessors, and set accessors.
Code
C#
class NamedHandle2
{
string name;
ulong handle = Handle.Allocate();
public NamedHandle2(string name) => this.name = name;
~NamedHandle2() => Handle.Release(handle);
public string Name
{
get => name;
set => this.name = value;
}
}
C#
class NamedHandle
{
string name;
ulong handle;
public NamedHandle(string name)
{
this.name = name;
handle = Handle.Allocate();
}
~NamedHandle()
{
Handle.Release(handle);
}
public string Name
{
get { return name; }
set { name = value; }
}
}