Bug 9056 - Byte.TryParse Exponent Parsing Inconsistant with Visual Studio
Summary: Byte.TryParse Exponent Parsing Inconsistant with Visual Studio
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-12-19 13:17 UTC by Brandon Vaughan
Modified: 2012-12-21 05:49 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Project with sample code. (5.44 KB, application/zip)
2012-12-19 13:17 UTC, Brandon Vaughan

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brandon Vaughan 2012-12-19 13:17:08 UTC
Created attachment 3111 [details]
Project with sample code.

Byte.TryParse gives different results on Mono and MS .Net when parsing exponents.  When parsing the text "4E+1", Mono returns null, but Visual Studio returns 40.  This is with NumericStyles.AllowExponent set on both VS and Mono.

Sample code:

using System;
using System.Globalization;

namespace ByteTryParseMono
    class MainClass
        public static void Main(string[] args)
            byte value;
            IFormatProvider english = new CultureInfo("en-US");
            //In Visual Studio, TryParse sets value to 40.  In Mono, value is set to null.
            bool succeeded = Byte.TryParse("4E+1", NumberStyles.AllowExponent | NumberStyles.Integer, english, out value);
            if (succeeded)
                Console.WriteLine("The converted text = " + value);
            } else
                Console.WriteLine("TryParse returned null");
Comment 1 Marek Safar 2012-12-21 05:49:09 UTC
Fixed already in Mono 3.0