C#判斷頁面中的多個文本框輸入值是否有重復(fù)的實現(xiàn)方法
本文實例講述了C#判斷頁面中的多個文本框輸入值是否有重復(fù)的實現(xiàn)方法,分享給大家供大家參考。具體實現(xiàn)方法如下:
//這里假如說有四個文本框
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ù)元素
{
//此時說明有重復(fù)
}
else
//說明沒有重復(fù)
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
C# 實現(xiàn)Table的Merge,Copy和Clone
這篇文章主要介紹了C# 實現(xiàn)Table的Merge,Copy和Clone,幫助大家更好的利用c#處理文件,感興趣的朋友可以了解下2020-12-12C#中使用Lambda表達式自定義比較器實現(xiàn)兩個列表合并實例
這篇文章主要介紹了C#中使用Lambda表達式自定義比較器實現(xiàn)兩個列表的合并實例,本文給出示例代碼和運行效果,需要的朋友可以參考下2014-10-10在winform下實現(xiàn)左右布局多窗口界面的方法之續(xù)篇
這篇文章主要介紹了在winform下實現(xiàn)左右布局多窗口界面的方法之續(xù)篇 的相關(guān)資料,需要的朋友可以參考下2016-02-02C#使用struct類型作為泛型Dictionary<TKey,TValue>的鍵
這篇文章介紹了C#使用struct類型作為泛型Dictionary<TKey,TValue>鍵值的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-08-08