码迷,mamicode.com
首页 > Windows程序 > 详细

C#判断页面中的多个文本框输入值是否有重复的实现方法

时间:2017-02-09 15:39:18      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:text   实现   next   没有   lis   判断   数组   输入   main   

List<string> list = new List<string>();//首先定义一个泛型数组

//这里假如说有四个文本框

string mainseat = this.textBox1.Text;
string nextseat = this.textBox2.Text;
string storeseat1 = this.textBox3.Text;
string storeseat2 = this.textBox4.Text;
if (mainseat != "")
{
list.Add(mainseat);
}
if (nextseat != "")
{
list.Add(nextseat);
}
if (storeseat1 != "")
{
list.Add(storeseat1);
}
if (storeseat2 != "")
{
list.Add(storeseat2);
}
if (list.Distinct().Count<string>() != list.Count)//排查数组中是否有重复元素
{
//此时说明有重复
}
else

//说明没有重复

C#判断页面中的多个文本框输入值是否有重复的实现方法

标签:text   实现   next   没有   lis   判断   数组   输入   main   

原文地址:http://www.cnblogs.com/Echo529/p/6382212.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!