Removal of Trailing Spaces from Datatable

@Shubham_Varshney
The Main Idea was following:

From r In dtData.AsEnumerable
Select ia = r.ItemArray.toList
Select ia.ConvertAll(Function (e) e.ToString.Trim).toArray

returns:
EnumerableRowCollection<string>
{
string[2]
{
“text”,
“silly Text”
},
string[2]
{
“I dont like Spaces”,
“Why?”
}
}

And with my silly trick from the past (hope you remember)

Assign: dtCorrected = yourDTVar.Clone

Assign: dtCorrected

(From r In dtData.AsEnumerable
Select ia = r.ItemArray.toList
Select ic = ia.ConvertAll(Function (e) e.ToString.Trim).toArray()
Select dtCorrected.Rows.Add(ic)).CopyToDataTable()

is doing:
[Column1,Column2
text,silly Text
I dont like Spaces,Why?
]

Here is the demo xaml: Shubham_SpaceCorrector.xaml (8.9 KB)

3 Likes