将字符串拆分为单个字符的字符串数组 [英] Split string into string array of single characters

查看:44
本文介绍了将字符串拆分为单个字符的字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想把这是一个测试"变成

new string[] {"t","h","i","s"," ","i","s"," ","a"," ","t","e","s","t"}

我真的需要做类似的事情吗

Would I really have to do something like

test = "this is a test".Select(x => x.ToString()).ToArray();

澄清一下,我不想要一个字符数组,理想情况下我想要一个字符串数组.除了我认为有更简单的方法之外,我并没有发现上面的代码有什么问题.

edit: To clarify, I don't want a char array, ideally I want an array of string. I don't really see anything wrong with the above code except for the fact that I would think there is an easier way.

推荐答案

我相信这就是您要找的:

I believe this is what you're looking for:

char[] characters = "this is a test".ToCharArray();

这篇关于将字符串拆分为单个字符的字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆