Linq to math round 3 decimals column of string

Hi

Hope this expression in assign activity would help you resolve this

dtData = (From r In dtData.AsEnumerable
let ra = r.ItemArray.Select(Function (x) Convert.ToDecimal(x.ToString.Trim).ToString(“F3”)).toArray()
Select dtCorrected.Rows.Add(ra)).CopyToDataTable()

Or

dtData = (From r In dtData.AsEnumerable
let ra = r.ItemArray.Select(Function (x) Math.Round(Convert.ToDecimal(x.ToString.Trim),3)).toArray()
Select dtCorrected.Rows.Add(ra)).CopyToDataTable()

Cheers @dyuonn.bakker

2 Likes