Complete the code to pass the integer value to the method.
int number = 5; ChangeValue([1]); void ChangeValue(int num) { num = 10; } Console.WriteLine(number);
Passing number directly passes the value, so changes inside the method do not affect the original variable.
Complete the method call to pass the integer by reference.
int value = 3; ModifyValue([1]); void ModifyValue(ref int val) { val = 7; } Console.WriteLine(value);
ref keyword in the method call.out instead of ref when the method expects ref.Using ref keyword passes the variable by reference, so changes inside the method affect the original variable.
Fix the error in the method call to correctly pass the value by output parameter.
int result; Calculate(out [1]); void Calculate(out int res) { res = 20; } Console.WriteLine(result);
ref instead of out in the call.out (which is allowed).The method expects an out parameter, so the call must use out keyword.
Fill both blanks to correctly pass and modify the value type using ref.
int count = 1; UpdateValue([1]); void UpdateValue([2] int num) { num = 100; } Console.WriteLine(count);
out keyword in method or call instead of ref.ref when method expects ref.The method parameter must have ref keyword, and the call must also use ref to pass by reference.
Fill all three blanks to create a method that takes a value type by in parameter and call it correctly.
int data = 50; DisplayValue([1]); void DisplayValue([2] int val) { Console.WriteLine([3]); }
in keyword in method or call.in).The method parameter uses in keyword to pass by readonly reference, so the call must also use in. Inside the method, print the parameter val.