Why doesnt this method call work?
Hi
I have the following code example:-
class Program
{
static void Sum(params int[] ints)
{
int sum = 0;
for (int i = 0; i < ints.Length; i++)
{
sum += ints[i];
}
}
static void Main()
{
int[] ints = { 1, 2, 3, 4 };
Sum(ints);
Console.WriteLine(ints);
Console.ReadLine();
}
}
I was expecting the calling method "Main" to reflect the changes in the called method "Sum" as the array of ints is passed by reference?
Regards
Steven