[Mono-list] Convert.ToSingle/Convert.ToDouble with empty string succeeds

Atsushi Eno atsushi at ximian.com
Thu Mar 16 12:03:21 EST 2006


Hi,

Colin JN Breame wrote:
> It appears that if you use Convert.ToSingle or Convert.ToDouble on an empty 
> string, the method succeeds and returns 0.
> 
> e.g.
> 
> public class test_t {
>         public static void Main() {
>                 System.Console.WriteLine(System.Convert.ToSingle(""));
>         }
> }
> 
> $ mcs test.cs && mono test.exe
> 0
> 
> I would expect it to throw a System.FormatException like Convert.ToInt32.  How 
> does this compare to the MS CLR behaviour?  Is this a bug or a feature?

It's a bug. Just fixed in svn. Thanks for the info.

Atsushi Eno


More information about the Mono-list mailing list