C#判断页面中的多个文本框输入值是否有重复的实现方法
本文实例讲述了C#判断页面中的多个文本框输入值是否有重复的实现方法,分享给大家供大家参考。具体实现方法如下:
List<string>list=newList<string>();//首先定义一个泛型数组
//这里假如说有四个文本框
stringmainseat=this.textBox1.Text; stringnextseat=this.textBox2.Text; stringstoreseat1=this.textBox3.Text; stringstoreseat2=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
//说明没有重复
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短