-1
Problem
I want to get the last digits of this string
, then I used the method Substring()
, however I had to use the variable "number" again within the method Substring()
.
string numero = "123456789";
string final = numero.Substring(numero.Length - 4);
Console.Write(final);
Is there any way to reference the variable numero
in its own method? Something like:
string final = numero.Substring(reference.Length - 4);
I used the word "Ference" just as an example, I am aware that the way this won’t work.
Because I want it
The way this is very simple to use the variable number, but in the code in which I need to perform this procedure the variable I am using is in a chain of methods and submethods, so the reference leaves the code confused. As a palliative I did the following:
string numero = referenciaMuitoGrandeBlaBla;
string final = numero.Substring(numero.Length - 4);
Console.Write(final);
Already help, however I did not want to use this way, since there may be a way to reference.
Interesting, I go from the +1, but still not the answer I’m looking for, because I really wanted the reference by ease, this way you did is cool, but it goes from more work than putting in a variable before the process as reference.
– Wictor Chaves