title: Looping through IEnumerable using ForEach in C#
body: <p>I'm trying to loop through an IEnumerable but for some reason it is not going through the foreach loop, as the values for each ChartClass was not modified.</p>
  
  <pre><code>public IEnumerable&lt;ChartClass&gt; get(string ID, string buildname, string placeholder)
      {
          var context = new Entities();
          var metrics = from c in context.VSTS_CODE_METRICS
                        where c.BUILD_NAME == buildname &amp;&amp; c.OBJECT_TYPE == "Namespace"
                        group c by c.BUILD_ID into g
                        select new ChartClass
                        {
                            Build_ID = g.Key,
                            BuildTrim = g.Key,
                            Index = g.Average(c =&gt; c.MAINTAINABILITYINDEX_).Value
                        };
          foreach (var i in metrics)
          {
              int num = i.BuildTrim.LastIndexOf('_');
              i.BuildTrim = "2";
          }       
          return metrics;
      }
  </code></pre>
  
  <p>I'm trying to change each ChartClass' BuildTrim field to "2" but it's not happening for some reason</p>