c# - Get inner array of a list without using ToArray() -
i have method needs list or array. don't want create overload because it's not trivial method. decided make this:
public float boundingbox(roadnode[] nodes)
the roadnodes have on client side in array , in list. when client has list have call toarray() on list , call method that's unacceptable copies items new array. performance big issue don't want time consuming. should do?
if you're enumerating on this, can change single signature:
public float boundingbox(ienumerable<roadnode> nodes)
if you're needing indexing behavior of both lists , arrays, can change signature to:
public float boundingbox(ilist<roadnode> nodes)
the first can more desirable, in can write code this:
public float boundingbox(ienumerable<roadnode> nodes){ ilist<roadnode> list; if (nodes ilist<roadnode>) list = (ilist<roadnode>)nodes; else list = nodes.tolist(); //do list }
Comments
Post a Comment