what's the best method to return a variable length string array
4 Answers
I'd prefer to use a generic collection such as: List<string> (or IList<string>), or IEnumerable<string> depending on how you plan to use it. Generic collections are typically easier to work with than arrays, having a much more robust interface.
7 Comments
toArray() member method.In the old .NET 1, there was the StringCollection class. it is still supported, and required in a few places, but I would prefer the generic List collection. Or there's the old C-style string[] as per the first answer.
You don't give any specifics, so everything else being equal, I would go for the generic list.