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 6743393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:57:20+00:00 2026-05-26T11:57:20+00:00

I have strings in a XML file that ment to be doubles (or float)

  • 0

I have strings in a XML file that ment to be doubles (or float) such as:

<VIPair>
<voltage>+100mV</voltage>
<current>+1.05pA</current>
</VIPair>

<VIPair>
<voltage>+5.00mV</voltage>
<current>+0.0035nA</current>
</VIPair>

The first pair will be “0.1” Volt and “0.00000000000105” Ampere.
The second pair would be “0.005” Volt and “0.000000000035” Ampere.

How can I convert them to double of float in C#?
Thanks.

P.S: I already can read them from xml file and at the moment I retrive them as string.

  • 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-05-26T11:57:21+00:00Added an answer on May 26, 2026 at 11:57 am

    Try with this:

    // Read string (if you do not want to use xml)
    string test = "<voltage>+100mV</voltage>";
    string measure = test.Substring(test.IndexOf('>')+1);
    measure = measure.Substring(0, measure.IndexOf('<')-1);
    
    // Extract measure unit
    string um = measure.Substring(measure.Length - 1);
    measure = measure.Substring(0, measure.Length - 1);
    // Get value
    double val = Double.Parse(measure);
    // Convert value according to measure unit
    switch (um)
    {
        case "G": val *= 1E9; break;
        case "M": val *= 1E6; break;
        case "k": val *= 1E3; break;
        case "m": val /= 1E3; break;
        case "u": val /= 1E6; break;
        case "n": val /= 1E9; break;
        case "p": val /= 1E12; break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a current Android app that uses i18n via resources. res/values-es/strings.xml and so
I have a string-array in my strings.xml file that has multiple items in it.
I have a helper class pulling a string from an XML file. That string
I have an XML configuration file with a collection of strings like so: <SomeSetting>value</SomeSetting>
I have a semi xml formatted file that contains line with the following format:
I have the localized strings file that is used in the Iphone app that
I have a DataTable that I'm creating an XML file from using .WriteXML(..), although
I have an asynctask that parses an xml file from the net. I'm storing
Hi there I have been trying to read an xml file with UTF strings,
I have gotten this error in the strings.xml file: error: Error parsing XML: unbound

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.