Skip to content

Adding deconstruction #98

Description

@desarrollo03TR

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;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions