How do we trim spaces of each item in a dt columns?

how do we trim spaces of each item in a dt columns ? without doing for each ?

for example I have dt result from readrange and I want to Trim each item in the columns so when I do
dt.Columns.Contains(test) the item in the dt columns already have been trimed. Thanks

Use below Code

List=(From col in dt.columns.CastOf(System.Data.DataColumns)
Select Convert.ToString( col ).Trim).ToList

You will get the column names without spaces.

Hope it will work

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.