0
I need to swap the first and second character.
Can someone please explain this? https://code.sololearn.com/cuZDCSXYQ9L3/?ref=app
4 ответов
+ 3
The Substring method (int,int) accept as first param the start index and as second the length of substring then yiur code get the original string least last two chars + the last + the one to last.
Use the following
return quot;{s1[1]}{s1[0]}"+s1.Substring(2);
+ 2
It use string interpolation (see https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated ) and essentially create a new string concatenint the original second char (s[1]), the original first char (s[0]) and the substring starting to index 2 from original (s1.Subtring(2))
0
KrOW
Can you desribe it more in laymern term? your code?
0
is it possible to not use string interpolation?