c# - .net: DataTable setting all non numeric values of data table as NULL -


need format datatable in .net, giving code below in vb.net

dim dt new datatable             dt.columns.add("a", gettype(system.string))             dt.columns.add("b", gettype(system.string))              dt.rows.add("n/a", "22")             dt.rows.add("99", "22.3")             dt.rows.add("not available", "#error")             dt.rows.add("5.5", "10") 

' need suggestions transform data table in .net c#/vb

'convert non numeric values of data table null, trying avoid looping , updating each row using regex

            'result dt             'a      b                    'null   22             '99     22.3             'null   null             '5.5    10 

hm if u don't need table contain non-numeric value begin , don't handed this, u can write own method add rows, checks before adding them if numeric or not.

otherwise can't think of preventing loop, if don't want use regex reasons can check if convertion possible (convert.todouble)


Comments