Passing immutable types by reference in Java and C#
To many, it should be obvious what the following code prints:
public static void main(String[] args){
int x=0;
SomeMethod(x);
System.out.println(x);
}
protected static void SomeMethod(int x){
x=1;
}
The code prints 0, because “int” is a native type and is passed by value. […]