我無法找到任何解決此錯誤的方法:/ im試圖將2個字母組合(例如aa ,ba,cb)乘以(aa * 3 = 4 * 3 ba * 2 = 3,5 * 2)。我的代碼是 ;c#無法將類型'System.Windows.Forms.Label'的對象轉換爲鍵入'System.Windows.Forms.TextBox'
string[] dersler = new string[9];
double[] kredi = new double[9];
double[] krediSonuclari = new double[9];
double derscarp(double s1, double s2)
{
return s1 * s2;
}
private void button1_Click(object sender, EventArgs e)
{
int i=0;
int j = 0;
foreach (TextBox item in Controls)
{
if (item.Name.Substring(0,7)=="txtders")
{
dersler[i] = Convert.ToString(item.Text);
i++;
}
}
foreach (TextBox item in Controls)
{
if (item.Name.Substring(0, 8) == "txtkredi")
{
kredi[j] = Convert.ToDouble(item.Text);
j++;
}
}
double toplam =0;
for (int k = 0; k < 9; k++)
{
您是否試過'調試'代碼?我的意思是在'調試'模式下運行 – 2013-05-13 14:32:00
線索出現在錯誤信息中...... – tomfanning 2013-05-13 14:32:32