title: Remove whitespace in elements in string C#
body: <p>I have a string which contains multiple items separated by commas :</p>
  
  <pre class="lang-cs prettyprint-override"><code> string RESULT =  "D_CA,     P_AMOUNT    ,D_SH,D_CU,D_TO,D_GO,D_LE,D_NU,D_CO,D_MU,D_PMU,D_DP,    P_COMMENT      ";
  </code></pre>
  
  <p>As you can see some elements contain Whitespaces,
  My object is to remove all the whitespaces,
  This is my code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    RESULT.Split(',').ToList().ForEach(p =&gt;
          if (p.Contains(" "))
          {
                 RESULT = RESULT.Replace(p, p.Trim());
          }
          });
  </code></pre>
  
  <p>And this is my result:</p>
  
  <pre><code>"D_CA,P_AMOUNT,D_SH,D_CU,D_TO,D_GO,D_LE,D_NU,D_CO,D_MU,D_PMU,D_DP,P_COMMENT"
  </code></pre>
  
  <p>it works well, But I ask if there is another more optimized way to get the same result?</p>