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

Colin JN Breame colin at breame.net
Thu Mar 16 10:16:33 EST 2006


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?

 -- Colin

PS. mono 1.1.13.4


More information about the Mono-list mailing list