Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Ref
- {
- class Program
- {
- static void Main(string[] args)
- {
- {
- int a = 4;
- int b = 3;
- int result; // unnecessary assigment of a value to result when we use out
- GetSum(a, b, out result);
- Console.WriteLine($"The sum from {a} and {b} is {result}.");
- }
- }
- private static int GetSum(int first, int second, out int result) // first and second are passed by value, but result is by reference
- {
- result = first + second;
- return result;
- }
- }
- }
Add Comment
Please, Sign In to add comment