如何实现点击按钮,删除文本框内相同号码?!急

Eason_wyf 2011-08-19 10:32:39
文本框的内容是以分号隔开,如:15855555555;15844444444;13955555555;15844444444;13955555555


点击按钮 如果有相同号码删除一个 。

如例子,点击删除按钮只剩3个号码。如何实现
...全文
94 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eason_wyf 2011-08-19
  • 打赏
  • 举报
回复
问题解决了 谢谢!
Eason_wyf 2011-08-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sunny906 的回复:]
C# code

String str = "15855555555;15844444444;13955555555;15844444444;13955555555";
String[] arr = str.Split(';');
List<String> list = new List<string>();
……
[/Quote]

这个没实现啊,我的是C/S的项目
baysos 2011-08-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gomoku 的回复:]
s = string.Join(";", s.Split(';').Distinct().ToArray());
[/Quote]
就这个了、
luluyy 2011-08-19
  • 打赏
  • 举报
回复


//以TextBox为例
Dictionary<string ,string> L_T=new Dictionary<string ,string>();
for(i=0;i<this.textbox1.Text.Length;i++)
{
if(!L_T.ContainsValue(substring(i,i+1)))//判断这个集合里面是否已经存在这个字符
{
L_T.Add(i,substring(i,i+1));
}
}
this.textbotx.text=集合里面的数据

笨方法 期待高手
sunny906 2011-08-19
  • 打赏
  • 举报
回复

String str = "15855555555;15844444444;13955555555;15844444444;13955555555";
String[] arr = str.Split(';');
List<String> list = new List<string>();
foreach (String s in arr)
{
if (!list.Contains(s))
{
list.Add(s);
}
}
String result = String.Join(";", list.ToArray());
Console.WriteLine(result);
gomoku 2011-08-19
  • 打赏
  • 举报
回复
s = string.Join(";", s.Split(';').Distinct().ToArray());

110,500

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧