Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. dot or comma?

dot or comma?

Scheduled Pinned Locked Moved C#
csharpquestionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ranger49
    wrote on last edited by
    #1

    Hello! I made a small C# application where you need to enter float numbers. In the Dutch language/math they write floating point numbers with a ',' so for instance 1,5 In English they write a dot like 1.5 The strange thing is that in my application only floating point number with a comma are entered correctly. Could someone tell me why this is? When I would enter 1.234 my program thinks it means 12.34, only when I type 1,234 this float is entering my program correctly... Could anybody tell me what is happening here, I would prefer to use the English version only! But maybe .NET sees that I have a Dutch PC? Ranger. Novice

    R A 2 Replies Last reply
    0
    • R Ranger49

      Hello! I made a small C# application where you need to enter float numbers. In the Dutch language/math they write floating point numbers with a ',' so for instance 1,5 In English they write a dot like 1.5 The strange thing is that in my application only floating point number with a comma are entered correctly. Could someone tell me why this is? When I would enter 1.234 my program thinks it means 12.34, only when I type 1,234 this float is entering my program correctly... Could anybody tell me what is happening here, I would prefer to use the English version only! But maybe .NET sees that I have a Dutch PC? Ranger. Novice

      R Offline
      R Offline
      Ranger49
      wrote on last edited by
      #2

      I have been looking around and found an interface called IFormatProvider but that this stuff is really complicated. It has to do with local standards, how countries have different ways of displaying things. Just like I expected. Can you switch off this local way of interpreting information? Ranger. Novice

      D 1 Reply Last reply
      0
      • R Ranger49

        I have been looking around and found an interface called IFormatProvider but that this stuff is really complicated. It has to do with local standards, how countries have different ways of displaying things. Just like I expected. Can you switch off this local way of interpreting information? Ranger. Novice

        D Offline
        D Offline
        DavidNohejl
        wrote on last edited by
        #3

        Ranger49 wrote:

        Can you switch off this local way of interpreting information?

        Yes, if you pass CultureInfo.InvariantCulture as IFormatProvider. -- modified at 8:08 Sunday 6th May, 2007


        "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

        R 1 Reply Last reply
        0
        • D DavidNohejl

          Ranger49 wrote:

          Can you switch off this local way of interpreting information?

          Yes, if you pass CultureInfo.InvariantCulture as IFormatProvider. -- modified at 8:08 Sunday 6th May, 2007


          "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

          R Offline
          R Offline
          Ranger49
          wrote on last edited by
          #4

          dnh wrote:

          Yes, if you pass CultureInfo.InvariantCulture as IFormatProvider.

          Thanks! This is exactly what I needed to know! Ranger. Novice

          1 Reply Last reply
          0
          • R Ranger49

            Hello! I made a small C# application where you need to enter float numbers. In the Dutch language/math they write floating point numbers with a ',' so for instance 1,5 In English they write a dot like 1.5 The strange thing is that in my application only floating point number with a comma are entered correctly. Could someone tell me why this is? When I would enter 1.234 my program thinks it means 12.34, only when I type 1,234 this float is entering my program correctly... Could anybody tell me what is happening here, I would prefer to use the English version only! But maybe .NET sees that I have a Dutch PC? Ranger. Novice

            A Offline
            A Offline
            AFSEKI
            wrote on last edited by
            #5

            Pass NumberFormatInfo as the IFormatProvider. Hope this helps...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups