0

How to write the last 3 characters of a string variable in new variable?

I have string variable FirsrtVar = "012345", I need take "345" from this variable and write in SecondVar. How to do it? (Sorry, I'm not english-speaker)

3rd Feb 2020, 8:22 PM
Albert
Albert - avatar
5 Answers
+ 2
Albert , you can use Substring method for example. Look at the code đŸ± https://code.sololearn.com/cimkWbs77Ebp/?ref=app
3rd Feb 2020, 8:27 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
Using Substring method. string firstVar = "012345"; string secondVar = firstVar.Substring(3); Substring is used like this: str.Substring( starting index, ending index) - if the second index is not provided, the string will go until the end
3rd Feb 2020, 8:30 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 2
a little tutorial: https://www.google.com/amp/s/www.geeksforgeeks.org/c-sharp-substring-method/amp/ SecondVar = FirstVar.Substring(3). //"345"
3rd Feb 2020, 8:31 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
I 2 hours searched information in Google and solved a problem for 5 minutes here)
3rd Feb 2020, 8:34 PM
Albert
Albert - avatar
0
Thank you)
3rd Feb 2020, 8:30 PM
Albert
Albert - avatar