110,549
社区成员
发帖
与我相关
我的任务
分享
Decimal D1 = Decimal.Parse(Label104.Text.Substring(0, Label104.Text.Length - 1));
D1 /= 100;
Label104.Text = D1.ToString();
Decimal D2 = Decimal.Parse(Label105.Text.Substring(0, Label105.Text.Length - 1));
D2 /= 100;
Label105.Text = D2.ToString();
Decimal D3 = Decimal.Parse(Label106.Text.Substring(0, Label106.Text.Length - 1));
D3 /= 100;
Label106.Text = D3.ToString();
....................
Decimal D193 = Decimal.Parse(Label297.Text.Substring(0, Label297.Text.Length - 1));
D193 /= 100;
Label297.Text = D193.ToString();
Decimal D194 = Decimal.Parse(Label298.Text.Substring(0, Label298.Text.Length - 1));
D194 /= 100;
Label298.Text = D194.ToString();
Decimal D195 = Decimal.Parse(Label299.Text.Substring(0, Label299.Text.Length - 1));
D195 /= 100;
Label299.Text = D195.ToString();
private void Form1_Load(object sender, EventArgs e)
{
var average = Controls.OfType<Label>().Select(l => ConvertStringToDecimal(l)).Where(d => d != 0M).Average();
textBox1.Text = average.ToString();
}
private decimal ConvertStringToDecimal(Label label)
{
var value = decimal.Parse(label.Text.Substring(0, label.Text.Length - 1)) / 100M;
label.Text = value.ToString();
return value;
}