Iterate over the strings, call ToCharArray() on them all and append those to a list of chars.
Do note that individual chars may be combining symbols and not standalone characters in their own right. If you care about that sort of thing you need to split your strings into logical character strings which is a bit harder.
I am stuck at …append those to a list of chars. Could you give me an additional suggestion?
/// Declare a variable for the input string and seperation characters.
string stringOriginal = null;
var stringList = new List<string>();
/// Check and store input values in the placeholders.
bool success1 = DA.GetData(0, ref stringOriginal);
bool success2 = DA.GetData(1, ref stringList);
/// Convert list of strings to array of characters
List<Char> listOfChars;
for (int i = 0; i < stringList.Count; i++)
{
Array chars = stringList[i].ToCharArray();
}
I was planning to check somehow that the input list contains single symbols, but I will do that after this.
using System;
using System.Linq;
using System.Collections.Generic;
public class Utility {
public char[][] ToCharacters(IEnumerable<string> strList) {
return strList.Select(str => str.ToArray()).ToArray();
}
}
If you want unique chars:
using System;
using System.Linq;
using System.Collections.Generic;
public class Utility {
public char[] ToUniqueCharacters(IEnumerable<string> strList) {
return strList.SelectMany(c => c).Distinct().ToArray();
}
}