0
What is the logic behind this code? The output is 34.
string str = "012345"; str = str.Substring(0); str = str.Substring(2); str = str.Substring(0,3); str = str.Substring(1,2); Console.Write(str); I want to understand it.
3 odpowiedzi
+ 6
Originally
<str> = "012345"
// From index 0 to the last
str = str.Substring(0); // "012345"
// From index 2 to the last
str = str.Substring(2); // "2345"
// From index 0, 3 characters
str = str.Substring(0,3); // "234"
// From index 1, 2 characters
str = str.Substring(1,2); // "34"
+ 2
Thank you Ipang. I was really confused.
+ 2
No problem bro 👌