I have a constructor in a collection that accepts IEnumerable. I want to enumerate and create a new collection using the items, but not reference the same items. Items can be value and ref types:
CustomCollection cc = new CustomCollection (IEnumerable<T> items)
{
foreach (var item in items)
{
this.Add(item); // justs adds the reference for ref types.
}
}
EDIT: .NET collections have the same methods and it doesn't do deep copy. Why would you wanna have a collection that is references the same elements as the original one?