1

For example I have this code

var person = new HighrisePerson()
{
    FirstName = firstName,
    ContactData = new HighriseContactData()
    {
        EmailAddresses = new List<HighriseEmailAddress>
        {
            new HighriseEmailAddress
            {
                Address = email,
                Location = "Work"
            }
        }
    }
};

I'd like to refactor to this:

var person = new HighrisePerson(firstName, email)

and I'd like this constructor added to my HighrisePerson Class

public HighrisePerson(string firstName, string email)
{
    FirstName = firstName,
    ContactData = new HighriseContactData()
    {
        EmailAddresses = new List<HighriseEmailAddress>
        {
            new HighriseEmailAddress
            {
                Address = email,
                Location = "Work"
            }
        }
    }
};
Myster
  • 17,704
  • 13
  • 64
  • 93
  • https://stackoverflow.com/questions/29678162/how-to-convert-a-c-sharp-object-initializer-to-use-a-constructor-using-resharper comes close : using R# structural search/replace – janv8000 Jun 23 '23 at 15:47

0 Answers0