Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most efficient way to place a list of drives in a ComboBox using C#?

I am creating a program that allows the user to select a drive letter from a combo box. I am debating between populating the box using a list or an array. What is the best and most efficient way to do this?

like image 655
Scott Boettger Avatar asked Dec 23 '22 06:12

Scott Boettger


2 Answers

For populating it, there is no discernible difference between a list and an array.

Personally, I would use a list as it is generally easier to use (can add/remove items, no fixed length etc.), and with generics, there is type safety just like an array. I know this has no difference in binding it to a list, but it makes it easier getting to that point.

like image 199
kemiller2002 Avatar answered Dec 24 '22 20:12

kemiller2002


'Efficient' is never going to be an issue here, with a max of 26 letters.

The combobox is going to copy to an internal list anyway, so as a source you can use whatever is most convenient.

like image 32
Henk Holterman Avatar answered Dec 24 '22 18:12

Henk Holterman