I read "most effective" as "fastest."
I wrote a quick test with a long string running 10 million times.
Austin's TrimEnd ran in 4.649s
My solution started in 1.927 seconds
int j = given.Length - 1; for (; j >= 0; j--) { char c = given[j]; if (c < '0' || c > '9') { break; } } var first = given.Substring(0, j + 1); var rest = given.Substring(j + 1);
Please note that my assemblies were not debugging (when debugging, my solution is slower, but this is because TrimEnd does not work in debug bits). So, if you use my code in your application and build debugging, it will be slower.
payo
source share