I’m not sure what is the best way to convert an IList<string> (IList does not implement the ToArray property) to an string[] array.
I cannot use Linq because I’m compiling with .NET 2.0. Any ideas will be wellcome.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
ICollection<T>.CopyTo:I’m not quite sure if I understand the no-LINQ restriction though? It sounds like you would use
ToArrayifIList<T>had it. But it turns out it does becauseIEnumerable<T>.ToArrayis an extension method defined onIEnumerable<T>of whichIList<T>implements. So why don’t you just use that?