I'm creating a function where I need to pass an object so that it can be modified by the function. What is the difference between:
public void myFunction(ref MyClass someClass)
public void myFunction(out MyClass someClass)
Which should I use and why?
ref tells the compiler that the object is initialized before entering the function, while
out tells the compiler that the object will be initialized inside the function.
ref is two-ways,
out is out-only.
ref modifier means that:
out modifier means that: