c# - How does Array.Reverse work? -
i have simple piece of code..
bool istrue(char[] number) { char[] reverse = number; array.reverse(reverse); }
when debugging application saw number reversed too. can explain me why? related how char arrays work, or missing something?
with
char[] reverse = number;
you not creating copy of array, reference it.
if want copy array, can use .clone()
:
char[] reverse = number.clone();
Comments
Post a Comment