本文實(shí)例講述了C#判斷頁面中的多個(gè)文本框輸入值是否有重復(fù)的實(shí)現(xiàn)方法,分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
//這里假如說有四個(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ì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選