I would like to confirm that the answer to https://stackoverflow.com/a/10387423/368896 is correct and applies in the following case:
// These IDataHolder instances contains a property "name",
// and another data member that is a large array.
// A copy constructor exists that makes a deep copy.
public MyFunction(IEnumerable<IDataHolder> columns)
{
// Is the copy constructor called?
this.columns = columns.ToDictionary(c => c.info.name, c => c);
}
I am fairly confident that the copy constructor is not called; i.e., that the call to toDictionaary
does not perform a deep copy but only copies references.
However, I cannot find confirmation of this.
Am I correct? Does toDictionary()
perform a shallow copy only?
(Note: I have a strong C++ background, but am new to C#.)