Make one custom class equal to another then delete the first

I am having a really annoying problem right now. Basically what i want to do is when i pick up an object it will pass (item) through a series of functions to place it into my inventory before ultimately being assigned to a slot, this is assigned as

	public void setItem(Item i)
	{
		item = i;
	}

The problem is when i destroy the object that this item script is attached to it blows up the reference to it too.

I would like to know if there is a function of sorts that will copy the object instead of just referencing it.

Create a copy constructor which does a deep copy of all the primitives

Okay, so it is impossible to do that, once it’s gone, it’s gone. But, if you aren’t concerned about the space, you can just move it. I would try this code:

void update()
if Item == 1
{
transform.Translate(Vector3.up, Space.World)
}
Item = 0
//if you "destroy" by pressing K
if input.getkey.k
{
    Item = 1
}
//Whatver you are wanting to use to get it back;
//in this case, it would be pressing P
if input.getkey.p
{
    spawn(Item)
    Item = 0
}