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.

14th Jan 2021, 11:05 AM
aka :)
aka :) - avatar
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"
14th Jan 2021, 11:40 AM
Ipang
+ 2
Thank you Ipang. I was really confused.
14th Jan 2021, 11:43 AM
aka :)
aka :) - avatar
+ 2
No problem bro 👌
14th Jan 2021, 12:27 PM
Ipang