This is messing with my mind, I've been trying to wrap my head around it for ages. I've been through a few questions on here and I still don't get it. I've visited Jon Skeet's page and etc. I tried writing my own code to see if I understood the concept but for the code below when I try to print out nums[0] it gives me 500, shouldn't it print out 1 since the array should have been passed by value because "C# passes by value by default" ?
UPDATE: aThing is just randomly changing an index to see if changes in r are reflected in nums
static void Main(string[] args)
{
int[] nums = new int[] { 1, 2, 3, 4 };
aThing(nums);
Console.WriteLine(nums[0]);
Console.ReadLine();
}
static void aThing(int[] r)
{
r[0] = 500;
r = null;
}
Just for interest's sake, how would I modify r without modifying numbs ?