C determines whether multiple text box input values in a page have a repeated implementation
- 2020-12-05 17:20:21
- OfStack
This article gives an example of C# to determine whether the input value of multiple text boxes in the page has a repeated implementation method, to share for your reference. Specific implementation methods are as follows:
List<string> list = new List<string>();// First of all define 1 A generic array
// So let's say there is 4 A text box
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)// Checks the array for duplicate elements
{
// Now there is repetition
}
else
// There is no duplication
Hopefully this article has helped you with your C# programming.