private void button1_Click(object sender, EventArgs e)
{
int v1 = Convert.ToInt32(textBox1.Text);
int v2 = Convert.ToInt32(textBox2.Text);
int v3 = Convert.ToInt32(textBox3.Text);
int v4 = Convert.ToInt32(textBox4.Text);
int v5 = Convert.ToInt32(textBox5.Text);
int v6 = Convert.ToInt32(textBox6.Text);
int v7 = Convert.ToInt32(textBox7.Text);
int v8 = Convert.ToInt32(textBox8.Text);
int v9 = Convert.ToInt32(textBox9.Text);
int v10 = Convert.ToInt32(textBox10.Text);
int n11 = Convert.ToInt32(textBox11.Text);
int n12 = Convert.ToInt32(textBox12.Text);
int n13 = Convert.ToInt32(textBox13.Text);
int n14 = Convert.ToInt32(textBox14.Text);
int n15 = Convert.ToInt32(textBox15.Text);
int n16 = Convert.ToInt32(textBox16.Text);
int n17 = Convert.ToInt32(textBox17.Text);
int n18 = Convert.ToInt32(textBox18.Text);
int n19 = Convert.ToInt32(textBox19.Text);
int n20 = Convert.ToInt32(textBox20.Text);
List<int> list = new List<int>() { v1, v2, v3, v4, v5, v6, v7, v8, v9 ,v10 };
List<int> list2 = new List<int>() { n11, n12, n13, n14, n15, n16, n17, n18, n19, n20 };
list = list.OrderBy(o => o).ToList();
list2 = list2.OrderBy(o => o).ToList();
list2.SequenceEqual(list);
}
喜evryone,這是這個項目,我需要幫助搞清楚如何在列表VS list2中比較值(數字)的第二部分, 例子,如果「清單」包含數5和「list2」也包含數字5,我需要一個真如果不是假的,順序並不重要,謝謝大家的幫助。文本輸入C#比較值和限制
您是否已經嘗試過任何一項功能? –
這裏是一個freebee的最簡單的部分'textBox1.MaxLength = 2;'其餘的你可以谷歌..有大量的例子在線做一個谷歌搜索'C#char.IsDigit'函數 – MethodMan
謝謝@MethodMan –