Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:53:32+00:00 2026-06-03T04:53:32+00:00

Update I’ve found the problem, the exception came from a 2nd field on the

  • 0

Update

I’ve found the problem, the exception came from a 2nd field on the same form which indeed should have prompted it (because it was empty)… I was looking at an error which I thought came from trying to parse one string, when in fact it was from trying to parse another string… Sorry for wasting your time.

Original Question

I’m completely dumbfounded by this problem. I am basically running int.Parse("32") and it throws a FormatException. Here’s the code in question:

private double BindGeo(string value)
{
    Regex r = new Regex(@"\D*(?<deg>\d+)\D*(?<min>\d+)\D*(?<sec>\d+(\.\d*))");
    Regex d = new Regex(@"(?<dir>[NSEW])");
    var numbers = r.Match(value);
    string degStr = numbers.Groups["deg"].ToString();
    string minStr = numbers.Groups["min"].ToString();
    string secStr = numbers.Groups["sec"].ToString();
    Debug.Assert(degStr == "32");
    var deg = int.Parse(degStr);
    var min = int.Parse(minStr);
    var sec = double.Parse(secStr);
    var direction = d.Match(value).Groups["dir"].ToString();
    var result = deg + (min / 60.0) + (sec / 3600.0);
    if (direction == "S" || direction == "W") result = -result;
    return result;
}

My input string is "32 19 17.25 N"

The above code runs on a .NET 4 web hosting service (aspspider) on an ASP.NET MVC 3 web application (with Razor as its view engine).

Note the assersion of degStr == "32" is valid! Also when I take the above code and run it in a console application it works just fine. I’ve scoured the web for an answer, nothing…

Any ideas?

UPDATE (stack trace)

[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9586043
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.Int32.Parse(String s) +23
   ParkIt.GeoModelBinder.BindGeo(String value) in C:\MyProjects\ParkIt\ParkIt\GeoBinder.cs:42

Line 42 is var deg = int.Parse(degStr); and note that the exception is in System.Int32.Parse (not in System.Double as was suggested).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:53:33+00:00Added an answer on June 3, 2026 at 4:53 am

    It turns out that this is a non-question. The problem was that the exception came from a 2nd field on the same form which indeed should have prompted it (because it was empty)… I was looking at an error which I thought came from trying to parse one string, when in fact it was from trying to parse another string…

    Sorry for wasting your time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[update] My bad.. I didn't look through the codes properly.. I should have spotted
[Update]: my initial example doesn't reflect my problem. Updated the sample, hopfully it is
Update: This does work, I was being stupid :( i have the following extension
UPDATE!!! Suggested answer is NOT correct, my mistake. The #container DIV should've had float:left;.
Update: Based on the answers I initially went the route of using IsInstanceOf() which
Update: This is, as I was told, no principle Python related problem, but seems
Update 2018 TL;DR; LaTEX for WPF https://github.com/ForNeVeR/wpf-math Original question I need to have a
Update I want to have an expression (XPath, or Regex Expression, similar) that can
Update 2: thanks again to @deepak-azad, I managed to solve my problem : here
UPDATE: Solution at bottom. I recently switched from using a set up such as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.