Remove space in column names from DataTable
<p>I have a <code>DataTable</code> which I populate from an excel sheet. The column names in the excel contain space between the two words i.e. </p>

<ol>
<li>PRODUCT TYPE</li>
<li>SERIAL NUMBER</li>
</ol>

<p>And I'm trying to achieve </p>

<ol>
<li>PRODUCTTYPE or PRODUCT_TYPE</li>
<li>SERIALNUMBER or SERIAL_NUMBER</li>
</ol>

<p>The <code>DataTable</code> columns are dynamically generated from the excel. I'm trying to remove the space between the words but I can't seem to get it to work. My current code for removing the white spaces looks like </p>

<pre><code>foreach (DataRow dr in cloned.Rows)
{
    foreach (DataColumn col in cloned.Columns)
    {
        dr[col] = dr[col].ToString().Replace(" ", "");
    }
}
</code></pre>

<p>can someone tell me where I'm going wrong please. </p>