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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:38:13+00:00 2026-06-03T02:38:13+00:00

I have a need to convert one string to another string (4 character always)

  • 0

I have a need to convert one string to another string (4 character always) as follows:

1.2 > 0102
99.1 > 9901
1 > 0100
1.44 > 0144

and then some other function to convert back from one string (4 character always) to another something like:

0102 > 1.2
9901 > 99.1
0100 > 1
0144 > 1.44

Can someone help by giving some suggestions as to how I could do this in C#?

Update:

Just to make it a bit more clear. There are really two zero padded double digit numbers. The one before the decimal and the one after. So 90.09 would need to convert to “90” + “09” = “9009”. I hope this makes sense

  • 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-03T02:38:14+00:00Added an answer on June 3, 2026 at 2:38 am

    I would use LINQ to solve it in one line:

    string oldString = "3.5";    
    string newString = string.Join("", from s in oldString.Split('.') select s.PadLeft(2, '0')).PadRight(4, '0');
    

    Reverting is easier:

    string oldString = "0305";
    string newString = oldString.Substring(0,2).TrimStart('0') + "." + oldString.Substring(2,2).TrimStart('0');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need to convert a string value in the form YYYYMMDDHHMMSS to
I have a millisecond timestamp that I need to convert from a string to
I have one function in oracle i need to convert it into c# code
I have problem i need to convert from my Array structure to std::vector<int> ...
I have a situation in which I need to convert a text data into
I have an situation where i need to convert Doc file into PDF file.
I have the following int 7122960 I need to convert it to 71229.60 Any
I need to convert the function path::combine(path1, path2). Please help me if you have
I have the following FORTRAN code which I need to convert to C or
I have an HTML help system that I need to convert to SharePoint. The

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.