使用管道符号将字符串添加到列表框中。 [英] Add items to Listbox from string saperated with Pipe symbol.

查看:139
本文介绍了使用管道符号将字符串添加到列表框中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串,我将从XElement下的服务器获取此数据,我已将其变为字符串,它看起来像是说

9000384454 | 130945522842 | 13098575900 | 917379563772 | 919014742532 | 99484575475

我需要解析才能添加这些数据

i需要将这些数字添加到列表框中列表框项目每当我得到一个管道符号,我该怎么做,我怎么能分开它们。

任何解决方案都将受到赞赏。

I have a string ,i will get this data from server under XElement, i have made it into a string and it looks like say
9000384454|130945522842|13098575900|917379563772|919014742532|99484575475
do i need to parse to add these kind of data
i need to add these each number into list box as listbox items whenever i get a pipe symbol, how can i do this , how can i separate them.
any solutions will be appreciated .

推荐答案

试试这个
string input = "9000384454|130945522842|13098575900|917379563772|919014742532|99484575475";
var items = input.Split(new []{'|'}, StringSplitOptions.RemoveEmptyEntries);
listBox1.DataSource = items;


这篇关于使用管道符号将字符串添加到列表框中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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