日期:2014-05-18 浏览次数:20811 次
textBox4.Text = (Convert.ToInt32(textBox1.Text) * Convert.ToInt32(comboBox1.Text) + Convert.ToInt32(textBox2.Text) * Convert.ToInt32(comboBox2.Text) + Convert.ToInt32(textBox3.Text) * Convert.ToInt32(comboBox3.Text)).ToString();
------解决方案--------------------
textBox4.Text = (Convert.ToInt32(textBox1.Text) * Convert.ToInt32(comboBox1.Items[0].ToString()) + Convert.ToInt32(textBox2.Text) * Convert.ToInt32(comboBox1.Items[1].ToString()) + Convert.ToInt32(textBox3.Text) * Convert.ToInt32(comboBox1.Items[2].ToString())).ToString();
------解决方案--------------------
用循环控制i的变化啊
------解决方案--------------------
TextBox[] textboxs = new TextBox[] { textBox1, textBox2, textBox3 }; int result = comboBox1.Items.OfType<object>().Select(x => Convert.ToInt32(x.ToString())).Zip(textBoxs.Select(x => Convert.ToInt32(x.Text)), (x, y) => x * y).Sum();