• Hugo Kornelis (9/27/2010)


    tommyh (9/27/2010)


    I dont agree with your arguments either. A string is either a number or its not. Not depending on what you try and convert it to. It should be one or the other.

    If that's your point of view, then you should be happy with the current implementation of ISNUMERIC. "2e1" is a valid number.

    I already said that all programming languages I have worked with recognise 1e2 as a floating point representation for 20 (1 x 102). I had at that time not yet verified your assertion that ".NET doesnt do this. Old VB6 does...". I have now. Using Visual Studio 2005, I opened a VB.Net project, edited a line to include the numeric constant "1e3", and I Visual Studio automatically changed it to "1000.0". I then tried the same with "1.23e-15", and VisualStudio changed that to "1.23E-15". Both versions could be compiled and executed.

    I then tried the same with a C# project. This time, the code was not changed, but it still compiled and executed without problems.

    So, I don't know who made you believe that .NET "doesnt do this" - but if I were you, I'd start double checking all other information from the same source, for it is apparently not the most reliable authority on .NET.

    That all being said, I completely fail to see the acutal use of a function that tells me that a string value "is either a number or its not". What good is it to know that a value is a number if I can still not convert it to a numerical data type without the risk of getting a runtime error? You may see a good use for such a function, but I don't.

    decimal.TryParse("2e1",out d) gives a False. Int version does the same. So right back at you.

    /T