将字符串分割在C#中没有分隔符(在某种程度上) [英] Split String in C# without delimiter (sort of)
本文介绍了将字符串分割在C#中没有分隔符(在某种程度上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要在拆分C#.NET中的字符串,看起来像这样:
I want to split a string in C#.NET that looks like this:
string Letters = "hello";
和把每个字母( H,E,L,L,O
)到一个数组或ArrayList中。我不知道该怎么在的分隔符使用String.Split(分隔符)
。我能做到这一点,如果原始字符串有逗号(或其他任何东西):
and put each letter (h, e, l, l, o
) into an array or ArrayList. I have no idea what to use as the delimiter in String.Split(delimiter)
. I can do it if the original string has commas (or anything else):
string Letters = "H,e,l,l,o";
string[] AllLettersArray = Letters.Split(",".ToCharArray());
但我不知道的情况下使用带(据说)没有分隔符。有没有像 Environment.Newline
特殊字符?谢谢你。
推荐答案
记住,你可以访问一个字符串在C#中的数组。
Remember, you can access a string as an array in c#.
字符串str =你好;
的char [] =字母str.ToCharArray();
这篇关于将字符串分割在C#中没有分隔符(在某种程度上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文