How to use Linq to substract two Column in a dataTable?

Can anyone help me?thank you very much!


You can directly use expression for that

Add new column using add data column of integer type

Then use assign

Dt.Columns("Gap").Expression = "[Price1] - [Price2]"


Thank you ,sir,actually, i know this way , but if I just want use Linq , how should i do?


Try this

Dt = dt.AsEnumerable.ToList.ForEach(function(x) x("Gap") = Cint(x("Price1")) - Cint(x("Price2"))


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