views:

40

answers:

2

I was using something like

public int Test(System.Windows.Forms.ListBox.ObjectCollection Colecction) { }

With this I want to pass just the ObjectCollection of the control, to sort, add and delete elements without passing the entire control, but someone told me that, this way of calling the collection, actualy, create an entire ListBox, making it a worst decition, than, passing a ListBox as a parameter.

Is it true? An if, what's the best way of working whit the collection?

A: 

No it doesn't create an entire list box. You're simply passing the Collection reference. If that's all you need to use this is fine. Though, you should realize there's no difference between passing in the Collection versus passing in the entire list box. They're both just passing references so neither one is more efficient than the other.

Spencer Ruport
A: 

I'm not entirely sure what you mean, but when you say passing the 'entire' control, remember you are only actually passing a reference to an object and not the whole object.

Charlie
Well, I always thought a ListBox passed as a parameter it was always passed as a reference, not the control itsef, but someone told me it wasn't, so I used that code.I guess there is no problem using one option or anotherThanks!