As far as I understand:
ref means passing the variable by reference, which means that you are passing a pointer to this variable, and it will save the changes after exiting the function.
out means basically the same thing, except that the variable must be assigned before the function is completed, almost the same as the return statements must be executed before the function completes.
source share