CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Value vs Reference Parameters

C# code walkthrough · Question 41
hardFunctions

Code

Read carefully. What does this print?
1void AddOne(int n) => n = n + 1;
2void BumpFirst(int[] arr) => arr[0] = arr[0] + 1;
3 
4int x = 5;
5int[] a = { 5 };
6AddOne(x);
7BumpFirst(a);
8Console.WriteLine(x + " " + a[0]);

Your answer