I'm writting a piece of code (c#) in windows phone 8 (had the same issue with windows 8).
And I am wondering, how to passe value of one object and not his reference.
Let me explain with one exemple :
public MyClass
{
private Foo foo //my object.
public void Init()
{
foo = new Foo();
foo.age = 5;
ChangeFooValue(foo);
}
private void ChangeFooValue(Foo temp)
{
temp.age = 10;
//I want to change temp and NOT foo.
//But at the end of this
//foo.age = 10;
//and
//temp.age = 10;
}
}
Solved : I had this in my class to create a deep copy :
public Foo DeepCopy()
{
Foo other = (Foo) this.MemberwiseClone();
return other;
}
ps: It's maybe a dumb question (if it is, please, provide me some tutorial to be able to resolve it by my self).