Can I set the newly created object equal to the supplied object in the constructor of the class?
I want to do something like this:
public MyClass
{
public MyClass(MyClassDto myClassDto)
{
MyClass convertedMyClassObj = AutoMapper.LoadEntityFromDto<MyProject.DTO.MyClassDto, MyClass>(myClassDto);
//Assign the new object being created here equal to convertedMyClassObj:
this = convertedMyClassObj; //I want to reference the current object in place of 'this'.
}
public int MyProperty1 { get; set;}
public int MyProperty2 { get; set;}
public int MyProperty3 { get; set;}
}
I don't want to do it property by property. Do I have to use a a singleton like procedure to return the copied instance in a GetInstance() method. Because constructor has no return parameter. I just want to know if this is possible or not.