我如何分割字符串成多个值? [英] How do i split a String into multiple values?
本文介绍了我如何分割字符串成多个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你如何分割字符串?
可以说我有一个字符串狗,猫,鼠,鸟
我的实际目标是每个那些动物插入到一个列表框,因此他们将成为一个列表框中的项目。
但我觉得我得到如何将这些项目,如果我知道如何分割字符串的想法。还是没有人知道一个更好的方式来做到这一点?
即时通讯使用ASP C#
解决方案
的String []标记= text.Split(''); 的for(int i = 0; I< tokens.Length;我++)
{
yourListBox.Add(新的ListItem(令牌[I],令牌[I]));
}
How do you split a string?
Lets say i have a string "dog, cat, mouse,bird"
My actual goal is to insert each of those animals into a listBox, so they would become items in a list box.
but i think i get the idea on how to insert those items if i know how to split the string. or does anyone know a better way to do this?
im using asp c#
解决方案
string[] tokens = text.Split(',');
for (int i = 0; i < tokens.Length; i++)
{
yourListBox.Add(new ListItem(token[i], token[i]));
}
这篇关于我如何分割字符串成多个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文