How can I convert ArrayList
into string[]
in C#?
To convert the contents of an ArrayList to a String, create a StringBuffer object append the contents of the ArrayList to it, finally convert the StringBuffer object to String using the toString() method.
So how to convert String array to String in java. We can use Arrays. toString method that invoke the toString() method on individual elements and use StringBuilder to create String. We can also create our own method to convert String array to String if we have some specific format requirements.
You can just put return null; or return new ArrayList(); since it looks like you don't care with what you're gonna get with the catch. You already have a console log.
string[] myArray = (string[])myarrayList.ToArray(typeof(string));
use .ToArray(Type)
string[] stringArray = (string[])arrayList.ToArray(typeof(string));
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