In this code snippet, we’ll take a look at what the ref keyword does in C#.
Variables can be passed either by value or by reference.
Usually, we do it by value meaning you pass just the value and not the variable itself. So, any changes made locally inside the method scope won’t be seen outside of the method scope.
Meanwhile, if we pass a variable as a reference is essentially like passing in the variable itself. Any changes made locally inside the method to the variable will occur outside of the method scope as well.
Let’s see the code example below.