Created
May 17, 2011 10:25
-
-
Save robgough/976254 to your computer and use it in GitHub Desktop.
passing by ref
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int AddOnePassByValue(int input) | |
{ | |
return input + 1; | |
} | |
public int AddOnePassByRef(ref int input) | |
{ | |
input + 1; | |
return -1; | |
} | |
public void main() | |
{ | |
int rob = 1; | |
output = AddOnePassByValue(rob); //OUTPUT rob=1, output=2 | |
output = AddOnPassByRef(rob); //OUTPUT rob=2, output=-1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment