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
I would use LINQ to solve it in one line:
Reverting is easier: