Questions tagged [formatexception]

FormatException is thrown when the format of an argument does not meet the parameter specifications of the invoked method.

FormatException is a .NET and Java exception thrown when the format of an argument does not meet the parameter specifications of the invoked method.

221 questions
113
votes
9 answers

Input string was not in a correct format

I'm new with C#, I have some basic knowledge in Java but I can't get this code to run properly. It's just a basic calculator, but when I run the program VS2008 gives me this error: I did almost the same program but in java using JSwing and it…
kustomrtr
  • 1,437
  • 2
  • 11
  • 14
47
votes
14 answers

Dart Unhandled Exception: FormatException: Invalid radix-10 number (at character 1)

I am trying to fetch some Data from the internet. So I made a API Request for a weather website. But I am getting the following exception- Unhandled Exception: FormatException: Invalid radix-10 number (at character 1). This is the error Code: …
Tom
  • 503
  • 1
  • 4
  • 8
21
votes
2 answers

Why does DateTime.Now.TimeOfDay.ToString("HH:mm:ss.ffffff") throw FormatException?

I'm having a similar problem with FormatException being thrown. My code is simply: void Orders_OnSubmit() { DateTime CurrentTime = DateTime.Now; rtbAdd( "Submitted on " + CurrentTime.Date.ToString("MM/dd/yyyy") + " at " +…
user1935160
  • 311
  • 1
  • 3
  • 8
12
votes
3 answers

How to deserialize a float value with a localized decimal separator with Jackson

The input stream I am parsing with Jackson contains latitude and longitude values such as here: { "name": "product 23", "latitude": "52,48264", "longitude": "13,31822" } For some reason the server uses commas as the decimal separator…
JJD
  • 50,076
  • 60
  • 203
  • 339
10
votes
1 answer

DatePicker System.FormatException

In this DatePicker if I type in an invalid date such as 1/1/20001 (enter key) I get the following exception A first chance exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: String was not recognized as…
paparazzo
  • 44,497
  • 23
  • 105
  • 176
10
votes
5 answers

Dynamically select columns in runtime using entity framework

I have an existing function like this public int sFunc(string sCol , int iId) { string sSqlQuery = " select " + sCol + " from TableName where ID = " + iId ; // Executes query and returns value in column sCol } The table has four columns…
pravprab
  • 2,301
  • 3
  • 26
  • 43
9
votes
3 answers

What is the .NET equivalent of Java's NumberFormatException?

Is FormatException in .NET the equivalent of NumberFormatException in Java ?
Kenzo
  • 1,767
  • 8
  • 30
  • 53
9
votes
4 answers

c# Convert.ToDouble format exception error

I'm trying to convert this string to double Convert.ToDouble("1.12"); and this is the output System.FormatException was unhandled. Should I do something like this? public static double ConvertToDouble(string ParseVersion) { double…
sczdavos
  • 2,035
  • 11
  • 37
  • 71
9
votes
2 answers

Why does FormatException not inherit from ArgumentException?

Is there a known reason why FormatException does not inherit from ArgumentException? An invalid format would seem to be a very specific case of an argument being invalid, similar to ArgumentOutOfRangeException. The MSDN article for the class…
Paul Turner
  • 38,949
  • 15
  • 102
  • 166
8
votes
4 answers

System.FormatException : Input string was not in a correct format ,on converting string to decimal.

I have a little problem with ASP.NET and C#. This is my error code: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in >user code Additional information: Input string was not in a correct…
user2855304
  • 83
  • 1
  • 1
  • 7
7
votes
4 answers

DRY string formatting

What is an elegant way to pull out common formats (e.g. datetime) for string.format into accessible constants? Ideally I would like to do something like the following, but I get the below error when I try to use this code. var now =…
Ryan Gates
  • 4,501
  • 6
  • 50
  • 90
7
votes
4 answers

Proper DateTime Format for a Web Service

I have a webservice with a method which is called via a xmlhttprequest object in my javascript. The method accepts a datetime parameter which is subsequently converted to a string and run against the database to perform a calculation. I get the…
user48408
  • 3,234
  • 11
  • 39
  • 59
6
votes
1 answer

System.FormatException: Input string was not in a correct format

private void ReadUnitPrice() { Console.Write("Enter the unit gross price: "); unitPrice = double.Parse(Console.ReadLine()); } This should work, but I'm missing something obvious. Whenever I input a double it gives me the…
Petrus K.
  • 840
  • 7
  • 27
  • 56
5
votes
2 answers

Decimal.Parse throws a FormatException

I tried to use the decimal.parse as described at : http://msdn.microsoft.com/en-us/library/cafs243z(v=vs.110).aspx So i copied from this page the following example: string value; decimal number; value = "1.62345e-02"; try { …
Eyal leshem
  • 995
  • 2
  • 10
  • 21
5
votes
3 answers

double.Parse throw a System.FormatException

I am trying to parse some string to a double value, using this parse method overload: double.Parse("198.222213745118", CultureInfo.CurrentUICulture); the CultureInfo.CurrentUICulture is fr-FR. but this is throwing an exception of type…
user2717436
  • 775
  • 1
  • 10
  • 23
1
2 3
14 15