I have a char array in one method, someObject is an arbitrary object passed by reference to the GetChars method:
private void DoSomeStuff(ref Object someObject)
{
char[] chars = GetChars(ref someObject); // {'a','b','c','d'}
char[] ReversedChars = Reverse(chars); // {'d','d','b','a'}
//chars and ReversedChars are in the same order, although "ref" is not used
}
private char[] Reverse(char[] someChars)
{
Array.Reverse(someChars);
return someChars;
}
Why is Array.Reverse in another method changing the original passed char array if not passing it by reference?