I have a class with multiple EventHandlers (among other things):
public GameObject
{
public event EventHandler<EventArgs> Initialize;
public event EventHandler<EventArgs> BeginStep;
....
}
I want to be able to add a Clone()
function to GameObject, which returns an exact duplicate of the object it was called on. I tried doing it like this:
public GameObject Clone()
{
var clone = new GameObject()
{
Initialize = this.Initialize,
BeginStep = this.BeginStep,
};
}
But, it appears that it is making clone.BeginStep
point to the same object as this.BeginStep
instead of making a copy. So, how do I make a copy of an EventHandler object?