ref keyword in C#
Hello guys, I'm just reading a bit about the
I have one question. I noticed that the
Can someone explain why ref should be used in both the arguments and parameters, why not use it either in argument or parameter
ref keyword. I understood that when we use that keyword, we tell the compiler that we want to directly work with the memory address of the variable and not a copy of it (when using it inside a method).I have one question. I noticed that the
ref keyword is used both when writing the arguments during the method call like callMethod(ref variable) and also during declaring the parameters of a method, we use the keyword, like static void changeValue(ref int x).Can someone explain why ref should be used in both the arguments and parameters, why not use it either in argument or parameter