Skip to content

Instantly share code, notes, and snippets.

@anelson
Created August 31, 2010 09:56
Show Gist options
  • Save anelson/558817 to your computer and use it in GitHub Desktop.
Save anelson/558817 to your computer and use it in GitHub Desktop.
Using return values, ref, and out parameters, Kyiv 2010
// When a method outputs two or more values, use output parameters and return void
public void GetUserInfo(out string userName, out string password) {
...
}
// When a method takes an argument for input, also changes the argument for output, use a ref parameter
//
// That said, a method that changes its input arguments like this is a very bad idea, so don't do it!
public void DontDoThis(ref User user) {
...
}
// A return value is useful when a method outputs a single value
public User CreateUserObject(string userName, string password) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment