Advertisement
Fhernd

PruebaSwap.cs

Nov 10th, 2017
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. class PruebaSwap
  2. {
  3.     static void Swap(ref string a, ref string b)
  4.     {
  5.         string temp = a;
  6.         a = b;
  7.         b = temp;
  8.     }
  9.  
  10.     static void Main()
  11.     {
  12.         string x = "Juan";
  13.         string y = "Oliva";
  14.         Swap(ref x, ref y);
  15.         Console.WriteLine(x);   // Oliva
  16.         Console.WriteLine(y);   // Juan
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement