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

Can anyone help me?thank you very much!

@491979546

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]"

Cheers

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

@491979546

Try this

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

Cheers

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