Normally, I'd choose List<String> [or, in VB, List(Of String)] over StringCollection whenever possible: see also Best string container.
However, as it seems, generics — and hence, List<String> — are apparently not supported in VS 2008's settings designer. Therefore, if I want to use a list of strings in my user settings, I have to resort to using a StringCollection there.
Now as I don't want to see StringCollection throughout my code, I need to convert it to List<String>. How do I do this efficiently? Or, even better, am I mistaken and there is a way to use List<String> in settings designer?
EDIT: I have to use .NET 2.0.
Converting StringCollection to List<string> is wonderfully simple if you're using .NET 3.5.
var list = stringCollection.Cast<string>().ToList(); Regarding your second question, I do seem to recollect that it is possible to use List<string> in the settings designer of Visual Studio. If you select custom type then browser to the appropiate type, it should work. However, I could be mistaken on that, so I'll need to verify it.
stringCollection.Cast<string>().ToList()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With