How to Convert Varchar Column in Datatable and Compute it using LINQ

In this blog, I will show you how to convert a string type column in a Datatable and compute it using the LINQ (from a single line of code).
 
Suppose I have a Datatable named _dtMain, containing a column named “iQty” with the datatype varchar. Now, using the given below single line of code, you can easily compute the values of the “iqty”.
 
 int iResult = _dtMain.AsEnumerable().Sum(x => Convert.ToInt32(x["iQty"]));