基本上我想做的就是拿一个字符串
string test = "hello";
然后将其转换为数组:
string[] testing = { "h", "he", "hel", "hell", "hello" };
这可能吗?
最佳答案
尝试使用Linq:
string test = "hello";
string[] testing = Enumerable
.Range(1, test.Length)
.Select(length => test.Substring(0, length))
.ToArray();
测试:
// h, he, hel, hell, hello
Console.Write(string.Join(", ", testing));
关于c# - 将字符串转换为带有字母的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40226690/