what's the best method to return a variable length string array
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.
There is nowhere near enough detail in your question to understand exactly what you are after.
This works though:
string[] GetStringArray(int length) {
return new string[length];
}
(C# isn't like C, if that is your concern.)
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