protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { int Total; foreach (string Str in ListBox1.Items) { Total = (Total + int.Parse(Str)); } TotalFees.Text = Total; }
TotalFees.Text = Total.ToString();
Cast<int>
foreach
int Total = ListBox1.Items.Cast<string>().Select(int.Parse).Sum();
int Total = 0; // set Total to zero to start foreach (string Str in ListBox1.Items) { Total = (Total + int.Parse(Str)); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)