Single.Parse(string) problem...
-
Hello everyone, i'm quite new to this c# world so please bear with me :) So I have this form and in it I have an editbox in which I must enter a number, in the following form : 119.43. Now, I need this string to be converted to float. Here's how I do it : float p = System.Single.Parse(prixS); BUT, I always get a string not properly formatted exception. I tried entering the price with a comma, no can do. Than I tried this : prixF = (float)System.Single.Parse(prix, System.Globalization.NumberStyles.AllowDecimalPoint| System.Globalization.NumberStyles.AllowTrailingWhite| System.Globalization.NumberStyles.AllowLeadingWhite); But again same error. Can someone please help me on this. Thanks for any help. Luc.
-
Hello everyone, i'm quite new to this c# world so please bear with me :) So I have this form and in it I have an editbox in which I must enter a number, in the following form : 119.43. Now, I need this string to be converted to float. Here's how I do it : float p = System.Single.Parse(prixS); BUT, I always get a string not properly formatted exception. I tried entering the price with a comma, no can do. Than I tried this : prixF = (float)System.Single.Parse(prix, System.Globalization.NumberStyles.AllowDecimalPoint| System.Globalization.NumberStyles.AllowTrailingWhite| System.Globalization.NumberStyles.AllowLeadingWhite); But again same error. Can someone please help me on this. Thanks for any help. Luc.
My freakin' bad :zzz: :mad: :(( :laugh: When fetching the text from the TextBox, I was using this.PriceEdit.ToString()... Ah ah ah !!! Wrong... This got me some undesired text in the string. I found that I need to use the TextBox.Text to access the text entered !!! Luc.