I have the following string: 0000015700
I need an algorithm that does the following:
0
from right to left (7
, in this case)7
going right to left (output would be 000157
It cannot be implemented using LINQ, since the project is running on the .NET 2.0 framework.
How do I do this in C#?
First you should trim end of string, and then get a required substring:
var tmp = str.TrimEnd('0');
var result = tmp.Substring(Math.Max(0,tmp.Length - 6));