| ||Reference types, Value types, and Patterns - slide 5 : 29|
Comparing and copying objects via references
Do we compare references or the referenced objects?
Do we copy the reference or the referenced object?
How deep do we copy objects that reference other objects?
- Reference comparison
- Compares if two references refers to objects created by the same execution of new
- Shallow and deep comparison
- Pair-wise comparison of fields - at varying levels
- Reference copying
- Shallow or deep copying
- Is also known as cloning
- Somehow supported by the method MemberwiseClone in System.Object
An assignment of the form var = obj1 copies a reference
A comparison of the form obj1 == obj2 compares references (unless overloaded)