Results 1 to 4 of 4

Thread: Convert a string in decimal

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Convert a string in decimal

    Hello, I have xml file with a number format that I have problems. because the number is coded .5 instead of 0.5, and even worse -. 5 instead -0.5. I know I can make the conversion to the simplest.

    Example, if string starts with '.' Or '-.' Then ....

    But as I have millions to import data in this format I am looking for your efficient suggestions.

    What do you think?

    Thank you in advance for your ideas.

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: Convert a string in decimal

    If you want to convert to a decimal format (types float, double, decimal).

    Code:
     using System. Globalization; 
      ... 
    
      chiffre1 string = ".5"; 
      chiffre2 string = "-. 5"; 
    
      CultureInfo ci = new CultureInfo ( "en-US"); 
      double1 double = double. Parse (chiffre1, ci); 
      double2 double = double. Parse (chiffre2, ci);

  3. #3
    Join Date
    Dec 2008
    Posts
    183

    Re: Convert a string in decimal

    hi
    would rather see in your regional options, you can display entire option as zero, you must put it on the correct format.
    Fast, simple and accurate ...


    This may help you.

  4. #4
    Join Date
    Dec 2008
    Posts
    202

    Re: Convert a string in decimal

    change the setting of the position to make a simple deserialization is a bit too much, especially when there is a solution as simple as that proposed by the other people on this forum ...

    Moreover, the numerical values in the text document are encoded in a standard format. So rather than go through the U.S. culture, especially through the invariant culture.

    Thus
    Code:
     CultureInfo ci = CultureInfo. InvariantCulture;

Similar Threads

  1. Replies: 3
    Last Post: 27-11-2010, 12:59 AM
  2. Convert float to 2 decimal place
    By SoftWore in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 01:22 PM
  3. c program to convert decimal to binary
    By Oswaldo in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 03:45 PM
  4. Can I convert decimal to string for mssql server?
    By Waffle in forum Software Development
    Replies: 3
    Last Post: 06-07-2009, 05:56 PM
  5. Convert binary to decimal in java
    By Seraphim in forum Software Development
    Replies: 2
    Last Post: 20-05-2009, 09:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,666,724.40585 seconds with 17 queries