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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:31:29+00:00 2026-05-29T21:31:29+00:00

I have the following string: string value = 123.456L; What is the best way

  • 0

I have the following string:

string value = "123.456L";

What is the best way to parse this string into a string and a double:

double number = 123.456;
string measure = "L"

Instead of the L, we could also have something else, like oz, m/s, liter, kilograms, etc

  • 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-29T21:31:30+00:00Added an answer on May 29, 2026 at 9:31 pm

    Assuming that the units of measure are always expressed as a single character at the back of the string, you can do this:

    string value = "123.456L";
    var pos = value.LastIndexOfAny("0123456789".ToCharArray());
    double number = double.Parse(value.Substring(0, pos+1));
    string measure = value.Substring(pos+1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string in the in the following format ,value,value2,3,(this is, a test),
I have the following C++ code std::map<std::string, std::vector<std::vector<std::vector<double> > > > details details[string][index][index].push_back(123.5); May
I have the following method: protected BigDecimal stringToBigDecimal(String value) throws ParseException { if (Pattern.matches([\\d,.]+,
suppose i have the following: boost::unordered_map< string , someValueType > map; someValueType& value =
I have the following string: <div id=mydiv>This is a div with quotation marks</div> I
I have the following XML in my web.config <mySectionGroup> <sectionOneSection> <page path=~/123.aspx></page> <page path=~/456.aspx></page>
If I have for example the following string: 123;3344;4334;12 and I want these numbers
I have the following string: [{EventType:1,ParticipantId:1,X:123,Y:123},{EventType:2,ParticipantId:1,ParrentList:[123,124,125,126],X:0,Y:0}] Could anybody give me an idea on how
Pythonistas: Suppose you want to parse the following string using Pyparsing: 'ABC_123_SPEED_X 123' were
I have the following string http://example.com/variable/controller/id32434242423423234?param1=321&param2=4324342 How in best way to extract id value,

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.