Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding deconstruction #98

Open
desarrollo03TR opened this issue Dec 21, 2017 · 0 comments
Open

Adding deconstruction #98

desarrollo03TR opened this issue Dec 21, 2017 · 0 comments

Comments

@desarrollo03TR
Copy link

desarrollo03TR commented Dec 21, 2017

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant