Hello Forum,
I have a collection class (inherited from System.Collections.CollectionBase). I want to return the contents in a list<>. I do this with the following function:
public List Clone()
{
List objMyCustomBlockList = new List();
MyCustomBlock[] objMyCustomBlockArray= new MyCustomBlock[this.List.Count];
this.List.CopyTo(objMyCustomBlockArray, 0);
objMyCustomBlockList.AddRange(objMyCustomBlockArray);
return objMyCustomBlockList;
}
Is there a faster way of doing this (performance)?
Is there a more elegant way of writing this code (less code)?
Thank you.

Manas MohapatraRank #182 · 13.2K reputationPosted Jul 23, 2016, 2:57 AM EDT
Ert Tre3 reputationPosted Jul 25, 2016, 8:21 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 25, 2016, 7:46 PM EDT
Looks good tome, except I didn't get the "this" part of the code. Is this an extension method?