Methods with In/Out parameters in C#
Forums:
void SwapStrings(ref string s1, ref string s2) {
var tmp = s1;
s1 = s2;
s2 = tmp;
}
var s1 = "A";
var s2 = "B";
SwapStrings(ref s1, ref s2);
//s1 is "B", s2 is "A"
- Log in to post comments