zoukankan      html  css  js  c++  java
  • 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

    //说明没有重复

  • 相关阅读:
    luogu4781
    luogu 4933
    luogu p1726
    bzoj2238
    luogu 1462 通往奥格瑞玛的道路
    noip.ac 3276 矩阵
    luogu1144
    noip.ac 3248
    奶牛比赛
    小P的Civilization V
  • 原文地址:https://www.cnblogs.com/Echo529/p/6382212.html
Copyright © 2011-2022 走看看