欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#判斷頁面中的多個(gè)文本框輸入值是否有重復(fù)的實(shí)現(xiàn)方法

 更新時(shí)間:2014年10月29日 11:20:37   投稿:shichen2014  
這篇文章主要介紹了C#判斷頁面中的多個(gè)文本框輸入值是否有重復(fù)的實(shí)現(xiàn)方法,是一個(gè)非常簡(jiǎn)單實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了C#判斷頁面中的多個(gè)文本框輸入值是否有重復(fù)的實(shí)現(xiàn)方法,分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
List<string> list = new List<string>();//首先定義一個(gè)泛型數(shù)組

//這里假如說有四個(gè)文本框

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)//排查數(shù)組中是否有重復(fù)元素
{
       //此時(shí)說明有重復(fù)
}          
else

       //說明沒有重復(fù)

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論