Java |
Primitive types are passed to methods by value (a copy is made),
while reference types are passed by reference.
Java cannot pass a primitive type as
a reference type. If you want to do so,
wrap the primitive type into a class.
|
|
C# |
Value types are passed to methods by value (a copy is made),
while reference types are passed by reference.
C# can pass a value type as
a reference type by marking it
with a ref keyword.
public void aMethod(ref int age, ref int ID){}
Note that you need to use the ref keyword in both
the method declaration and the actual call to the method.
aRef.aMethod(ref age, ref ID);
|
|