Question
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 then double). If conversion works, the return true. If an exception is thrown, return false.
- Regular expressions designed to match the pattern of an int or double
- Some other method?
Answer
Would use double.TryParse, it has performance benefits.
< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/1995/" >Most Efficient Way to Test Object Type< /a>
0 comments:
Post a Comment