I have values stored as strings in a DataTable where each value could really represent an int, double, or string (they were all converted to strings during an import process from an external data source). I need to test and see what type each value really is.
What is more efficient for the application (or is there no practical difference)?
- Try to convert to
int(and thendouble). If conversion works, the returntrue. If an exception is thrown, returnfalse. - Regular expressions designed to match the pattern of an
intordouble - Some other method?
Would use double.TryParse, it has performance benefits.