Friday, September 26, 2014

char array to string array

This converts a char array to a string array:



char[] chars = { 'a', ' ', 's', 't', 'r', 'i', 'n', 'g' };
string[] strings = null;
Array.Resize(ref strings, chars.Length);

for (int i = 0; i < chars.Length; i++) {
strings[i] = new string(chars[i], 1);
}





"If there's nothing wrong with me, maybe there's something wrong with the universe!"


No comments:

Post a Comment