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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -