Filtering only numeric values through LINQ



If we have a column with numeric, alphabetical and alphanumeric values, how can we use LINQ to filter out only the numeric values?

I tried something like DT.Select(“ColumnName NOT LIKE”+regex) but it isn’t working.


In this case, you might use the .Where in instead of .Select cause I think it’s more flexible and easier to understand.

dt.AsEnumerable().Where(Function(row) IsNumeric(row(column).ToString.Trim)).ToArray()
will return an array of DataRows
dt.AsEnumerable().Where(Function(row) IsNumeric(row(column).ToString.Trim)).CopyToDataTable()
will convert your filtered table to a dataTable

You can also use a Regex pattern as your condition, but if you just need to know if it’s a number you can use IsNumeric()

Hope this helps. Thanks.


Hi @ClaytonM

Thanks…this works!

Do you happen to know if there’s any online resource to know about such commands? Since I don’t have prior .Net experience I wasn’t aware of commands such as dt.AsEnumerable().Where()


I don’t really know of a good resource, but what I do normally (cause I don’t remember how to do certain things) is search in Google and you’ll find many examples in C# and UiPath uses mostly but you can adjust the syntax from C# if you know the difference (which is basically uses “Function(x)” instead of “x =>”).