ImmutableObjectGraph
ImmutableObjectGraph copied to clipboard
Adding deconstruction
It would be nice if a deconstruct method is auto generated.
Example:
public class Person
{
public string FirstName { get; }
public string LastName { get; }
public string City { get; }
public string State { get; }
public Person(string fname, string lname, string cityName, string stateName)
{
FirstName = fname;
LastName = lname;
City = cityName;
State = stateName;
}
public void Deconstruct(out string fname, out string lname, out string city, out string state)
{
fname = FirstName;
lname = LastName;
city = City;
state = State;
}
}
With:
var person = new Person("aName", "aLastName", "aCity", "aState");
Deconstruction can be used like:
var (first, last, city, state) = person;
Or:
var (first, last, _, _) = person;