The ref
keyword is used to pass an argument by reference, not value. The ref
keyword makes the formal parameter alias for the argument, which must be a variable. In other words, any operation on the parameter is made on the argument.
For example:
void Method(ref int refArgument)
{
refArgument = refArgument + 44;
}
int number = 1;
Method(ref number);
Console.WriteLine(number);
// Output: 45
So to answer your question, no the ref
keyword does not “copy” the variable.
You can read more about the ref
keyword here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref
solved Does c#’s ref copy and how to prevent it? [duplicate]