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<MyCustomBlock> Clone()
{
List<MyCustomBlock> objMyCustomBlockList = new List<MyCustomBlock>();
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.