I’m trying to call a method but it’s telling me that I need to pass in an array. There is no Convert.ToArray() method, and casting doesn’t work.
How can I convert a list to an array?
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.
Call the ToArray() method on your list object. I have provided a link to the documentation.
This documentation refers to the System.Collections.Generic namespace which is available in all versions of .NET unlike the more specialized linq namespace. They do perform the same function, however no details on performance comparisons are provided here.
MSDN documentation on List.ToArray Method
Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
public T[] ToArray()