title: c# - How to get sum of the values from List?
body: <p>I want to get sum of the values from list.</p>
  
  <p>For example: I have 4 values in list
  1 2 3 4 I want to sum these values and display it in Label</p>
  
  <p>Code:</p>
  
  <pre><code>protected void btnCalculate_Click(object sender, EventArgs e)
  {
      string monday;
      TextBox txtMonTot;
      List&lt;string&gt; monTotal = new List&lt;string&gt;();
  
      if (Application["mondayValues"] != null)
      {
          List&lt;string&gt; monValues = Application["mondayValues"] as List&lt;string&gt;;
          for (int i = 0; i &lt;= gridActivity.Rows.Count - 1; i++)
          {
              GridViewRow row = gridActivity.Rows[i];
              txtMonTot = (TextBox)row.FindControl("txtMon");
              monday = monValues[i];
              monTotal.Add(monday);
          }
      }
  }
  </code></pre>
  
  <p>Any ideas? Thanks in advance</p>