In C#, parameter modifiers are keywords or attributes applied to method parameters to specify certain behaviors or constraints. There are several parameter modifiers available in C#:

ref: Indicates that a parameter is passed by reference, allowing the method to modify the value in the calling method. (An example is provided in the code below. Through “ref,” if there is a value initialized similar to C++ addresses, the method can change that value from inside or outside. However, the variable must already have a value initialized. Must have value initialized. āύāĻŋāĻšā§‡āϰ āϕ⧋āĻĄā§‡ āωāĻĻāĻžāĻšāϰāύ āφāϛ⧇āĨ¤ āϰ⧇āĻĢ āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ C++ āĻāϰ āĻāĻĄā§āϰ⧇āϏ⧇āϰ āĻŽāϤ⧋ āϕ⧋āύ⧋ āĻ­ā§āϝāĻžāϞ⧁ initialized āĻ•āϰāĻž āĻĨāĻžāĻ•āϞ⧇ āϤāĻžāϰ value change āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇ method āĻĨ⧇āϕ⧇ āĻŦāĻž āĻŦāĻžāχāϰ⧇ āĻĨ⧇āϕ⧇āĨ¤ āϤāĻŦ⧇ āφāϗ⧇ āĻĨ⧇āϕ⧇āχ veriable  āĻ āĻ­ā§āϝāĻžāϞ⧁ āĻĨāĻžāĻ•āϤ⧇ āĻšāĻŦ⧇āĨ¤ āĨ¤ Must have value initialized)


out: Similar to “ref,” used for output parameters, indicating that the parameter does not need to be initialized before being passed. (An example is given in the code below. Through “out,” it can also initialize a variable similar to C++ addresses, which will get its value assigned from outside. However, the variable cannot have a value initialized beforehand. Never have value initialized. āύāĻŋāĻšā§‡āϰ āϕ⧋āĻĄā§‡ āωāĻĻāĻžāĻšāϰāύ āφāϛ⧇āĨ¤ āφāωāϟ āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āĻ“ C++ āĻāϰ āĻāĻĄā§āϰ⧇āϏ⧇āϰ āĻŽāϤ⧋ āϕ⧋āύ⧋ variable āĻ value initialized āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇ āϝāĻž āϭ⧇āϰāĻŋā§Ÿā§‡āĻŦāϞ⧇ āϏ⧇āϟ āĻšā§Ÿ āĻŦāĻžāχāϰ⧇ āĻĨ⧇āϕ⧇āĨ¤ āϤāĻŦ⧇ āφāϗ⧇ āĻĨ⧇āϕ⧇āχ veriable  āĻ āĻ­ā§āϝāĻžāϞ⧁ āĻĨāĻžāĻ•āϤ⧇ āĻĒāĻžāϰāĻŦ⧇ āύāĻžāĨ¤ Never have value initialized)

params: Allows a variable number of arguments of the same type to be passed to a method using an array.

this: Used in extension methods to indicate the type that the method operates on. Keep in mind, No, the ‘this’ keyword cannot be used within a static method in C#. āĻŽāύ⧇ āϰāĻžāĻ–āĻŋ, No, the 'this' keyword cannot be used within a static method in C#

in (C# 7.2 and later): Indicates that a parameter is read-only, optimizing for performance and preventing modification within the method. (In is only readonly)
// ..............Normal method................
int x = 10;
SimpleMethod(x);
Console.WriteLine("Ans of simple method: " + x); // Ans: 10
 
static void SimpleMethod(int parameter)
{
    parameter += 20;
}
 
// ..............ref................
int y = 200;
RefMethod(ref y);
Console.WriteLine("Ans of ref: " + y); // Ans: 500
 
static void RefMethod(ref int parameter)
{
    parameter += 300;
}
 
// ..............out................
int z;
OutMethod(out z);
Console.WriteLine("Ans of out: " + z); // Ans: 7000
 
static void OutMethod(out int parameter)
{
    parameter = 7000;
}
 
// ..............params................
 
int sum1 = Add(1, 2, 3, 4, 5);
int sum2 = Add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
 
Console.WriteLine("Ans: " + sum1); // Ans: 15
Console.WriteLine("Ans: " + sum2); // Ans: 55
 
static int Add(params int[] parameters)
{
    int result = 0;
    foreach (var x in parameters)
        result += x;
    return result;
}
 
// ..............in................
 
int x = 10;
InMethod(in x);
 
static void InMethod(in int parameter)
{
    // parameter += 20; // We can't do that because in is just readonly
    Console.WriteLine(parameter);
}
 
// ..............this................
 
using System;
 
class MyClass
{
    private int myNumber;
 
    public MyClass(int number)
    {
        this.myNumber = number;
    }
 
    public void DisplayNumber()
    {
        Console.WriteLine("My number is: " + this.myNumber);
    }
}
 
class Program
{
    static void Main(string[] args)
    {
        MyClass obj = new MyClass(10);
        obj.DisplayNumber();
    }
}