I would like to initialize a new string array from the values contained in a char array.
Is this possible without using a list?
This is what I have so far:
char[] arrChars = {'a', 'b', 'c'};
string[] arrStrings = new string[](arrChars);
string[] arrStrings = Array.ConvertAll(arrChars, c => c.ToString());
Why not use a for loop for your initialization? Or, if that's too many LOC, you could just use Linq:
string[] arrStrings = arrChars.Select(c => c.ToString()).ToArray();
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