Hi guys,
I've started study c# a few days ago and I'm wondering what's the best practice (general) when you have something like this:
class MyClass
{
List<AnotherCustomClass> MyList { get; set; }
}
As far as I know, what happen is that the compiler replace the set property with something like
public setMyList(List<AnotherCustomClass> anotherList)
{
MyList = anotherList;
}
just copying the reference. In a scenario like this MyList and anotherList point to the same object so, inside MyClass, I'm going to modify an external object and, as far as I know, this isn't a good practice.
Do I need to implement IClonable interface for my types and make a deep copy when I encounter situation like the one I showed above?
Thank you,
johnnie