I have a FullClass with some values. I want to copy some of it's values and hold it as a copy so I created coresponding CopyClass. How can I rewrite this code to achieve object creation without new keyword and just by assigning value like in the example - for simpler use.
class FullClass
{
public int x;
public int y;
public int z;
}
class CopyClass
{
public int x;
public int y;
public CopyClass(FullClass fullObject)
{
x = fullObject.x;
y = fullObject.y;
}
}
void AssignCopyObject()
{
//I want small copy of FullClass with some of it's values
CopyClass copyObject;
//How I create small class object
copyObject = new CopyClass(fullObject);
//How I want to create it automaticly by using assign of full class object
copyObject = fullObject; //ofc doesn't work
}