当前位置: 移动技术网 > IT编程>开发语言>c# > C#判断页面中的多个文本框输入值是否有重复的实现方法

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

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#判断页面中的多个文本框输入值是否有重复的实现方法,分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:
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#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网