Ref, Out, In Parameters
Ref, Out and In keywords in C# are used to pass arguments within a method or function. These keywords indicate that an argument/parameter is passed by reference. The normal parameter what we studied before is passed by value. In order to declare Ref, out and in parameter, we need to go before parameters and use ref, out or in keyword.
Before C# version 7.2, there are only ref and out keywords for passing the references of a variable. Out is meant for output only whereas ref is meant for both input and output. However, if we had to pass a read-only reference, i.e., passing a variable as input only, then there was no direct option for that. So, in C# 7.2, in parameter has been introduced.
So far we created lot of methods with parameters. We haven't used ref, out or in keyword before any parameters hence all those parameters are called as normal parameters. All ref, out and in parameters are call by reference type. Now we going to see how system will work if we use ref, out and in parameter. But before studying that we need to know the difference between these 3 parameters. Apart from the difference what mentioned below all 3 ref, out, in Parameter work in a same way.
CODE
EG 1 . Creating a method with ref parameters
class Program {
    static void Addition(ref int number1, ref int number2) {
        //Addition method may or may not assign the value of ref parameters
        Console.WriteLine(number1 + number2);
    }
    static void Main(string[] args) {
        //Referring the memory of num1 and num2 of main method to number1 and number2 of Addition method.
        int num1 = 5, num2 = 6;
        Addition(ref num1,ref num2);
    }
}
EG 2 . Creating a method with out parameters
class Program {
    static void Addition(out int number1, out int number2) {
        //Addition method must assign the value of out parameters
        number1 = 17; number2 = 9;
        Console.WriteLine(number1 + number2);
    }
    static void Main(string[] args) {
        //It doesn't make any sense assigning num1 and num2 values here because value assigned in Addition method will only taken.
        int num1 = 5, num2 = 6;
        Addition(out num1,out num2);
    }
}
EG 3 . Creating a method with in parameters
class Program {
    static void Addition(in int number1, in int number2) {
        //Addition method cannot assign the value of in parameters
        Console.WriteLine(number1 + number2);
    }
    static void Main(string[] args) {
        //While invoking we must assign the value of in paramters number1 and number2.
        int num1 = 5, num2 = 6;
        Addition(in num1,in num2);
    }
}
(Click Here, For more exercises)