+ 1
Why is my method changing the original value
2 ответов
+ 6
~LoneWolf
Because reference is same.
You have passed str as a parameter and assigned to tempArr so reference of str and tempArr is same.
Solution is clone the original array then assign to tempArr like this:
string[] tempArr = (string[]) arr.Clone();
https://code.sololearn.com/c2oGVT26RGH6/?ref=app
+ 2
A͢J thanks for the solution😀👍