本文介绍了将字符串的值更改为字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我碰巧有一个字符串,其格式为:''me,you,i,jane,'''',我想借助数组将其值更改为单个单词的集合例如''''me'''',''''you'''',''i'''',''jane''''
i happen to have a string thats in this format: ''''me, you, i, jane,'''' and i would like to change its values into a collection of individual words with the help of an array e.g ''''me'''', ''''you'''', ''''i'''', ''''jane''''
推荐答案
string[] arr = my.Split(new char[]{'',''});
按您希望的方式操纵数组的顺序,然后再次创建字符串.
Manipulated the order of the array any way you wish and create the string again.
myString = String.Join(",", Array);
string[] words = my.Split('','');
for(int wi = 0; wi < words.Length; wi++) wi[i] = wi[i].Trim();
如果您不关心空格,则自行拆分即可.
If you don''t care about white space, Split on its own will do the job.
string[] array = myString.Split(new char[] { '','', '' '' }, StringSplitOptions.RemoveEmptyEntries);
这样可以为您删除逗号和空格.
That removes commas and blanks for you.
这篇关于将字符串的值更改为字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!