基本上,下面的第一个 for 语句会根据用户输入创建一个 testvalue 标签列表。
第二个 for 语句应该计算出创建的动态标签的总数,但是当我播放它时,我收到一条错误消息,说“输入字符串的格式不正确”。tots += double.Parse(value[p].ToString());
任何帮助将不胜感激。 谢谢
ArrayList value = new ArrayList();
int p =0;
for (int i = 0; i < weight.Count; i++)
{
Label test = new Label();
System.Drawing.Point l8 = new System.Drawing.Point(440, 48 + s);
test.Location = l8;
value.Add(test);
k += 35;
Label l2 = testpercent1[i] as Label;
Double.TryParse(l2.Text.Trim(), out label2);
Label l = testpercent2[i] as Label;
Double.TryParse(l.Text.Trim(), out label1);
Double testvalue = Math.Round(((label1 * .3) + (label2 * .4)));
test.Text = testvalue.ToString();
}
Double total = 0;
for (int p = 0; p < value.Count; p++)
{
tots += double.Parse(value[p].ToString());
}