Probably you meant dt.Compute( $"{a} / {b}", string.Empty )
.
C# Calculation using Data Table Compute
I have been using C# Datatable.Compute function to do calculations.
Example:Dot net version 5.0
Given that , Datatable dt = new Datatable();
var a=4000
var b =24
var str = dt.Compute((a/b).ToString(), string.Empty);
The gen0 garbage collector invocation for this single operation is high.
Could you suggest an alternate function to this?
Regards,
Thomas Jacob
Developer technologies C#
2 answers
Sort by: Most helpful
-
Viorel 122.5K Reputation points
2023-05-04T18:36:35.1+00:00 -
Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
2023-05-04T19:11:41.95+00:00 its a rather heavy operation. the expression must be parsed, converted to il code, then loaded as an assembly.
note: if lambda existed, when designed, than they probably would have been used, and the expression compiled at build instead of runtime.