Pass A Reference To A Function, Method, etc
Passing by reference enables function members, methods, properties, indexers, operators, and constructors to change the value of the parameters and have that change persist in the calling environment.
You just use the ‘ref’ or ‘out’ keyword:
‘ref’ tells the compiler that the object is initialized before entering the function
‘out’ tells the compiler that the object will be initialized inside the function
So ‘ref’ is two-ways and ‘out’ is out-only
public void MyMethodName(ref int[] BookIds, ref string[] BookLanguages)
{
//or:
public void MyMethodName(out int[] BookIds, out string[] BookLanguages)
{
Calling the method
You need to use the ‘ref’ or ‘out’ keyword here too
MyMethodName(ref TheBookIds, ref TheBookLanguages);
