C#判断页面中的多个文本框输入值是否有重复的实现方法
本文实例讲述了C#判断页面中的多个文本框输入值是否有重复的实现方法,分享给大家供大家参考。具体实现方法如下:
//这里假如说有四个文本框
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#程序设计有所帮助。
相关文章
C#中Hashtable与Dictionary的用法对比及选择
这篇文章主要介绍了C#中Hashtable与Dictionary的用法对比及选择方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2025-03-03
C#如何在WinForm中打开Excel文件,或打开Excel应用显示数据
这篇文章详细介绍了如何在WinForm中打开Excel文件,并提供了相关的代码解释、数据插入、单元格格式设置和页面格式设置的方法2024-12-12


最新评论