CJCoding With Joseph
← Back to Question List
C# Code Walkthrough #41

Value vs Reference Parameters

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