I have a boolean that returns true or false after looking at some boolean arrays and ints.
if (CheckForRoute(VertWallAbove, HoriWallLeft, NewWallX, NewWallY, NewWallHor))
During this function the parameter that comes from HoriWallLeft has its value[0,0] set to true (Prior to this every value in the array is false and I have checked this is happening with breakpoints). immediately after exiting the function the value of HoriWallLeft[0,0] is true, I would've thought this would only happen if I am passing by ref.
Edit: Here is an example of what I mean
static void Main(string[] args)
{
bool[] Test = new bool[] { false, false, false, false };
ExampleFunction(Test);
if(Test[0])
{
Console.WriteLine("A");
}
else
{
Console.WriteLine("B");
}
Console.ReadLine();
}
static bool ExampleFunction(bool[] TestArray)
{
TestArray[0] = true;
return true;
}
I would expect this to output B but it outputs A
This is correct, you are passing a reference to this array to the Function. There is no copy of the array created.
If you want a copy to be created, you could call
ExampleFunction(Test.ToArray());