Created
October 27, 2009 07:53
-
-
Save kentaromiura/219404 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
public class MyClass | |
{ | |
public static void Swap<T> (T a , T b){ | |
T x = a; | |
a = b; | |
b = x; | |
} | |
public static void RealSwap<T>(ref T a,ref T b){ | |
T x = a; | |
a = b; | |
b = x; | |
} | |
public static void RunSnippet() | |
{ | |
System.Text.StringBuilder a,b; | |
a= new System.Text.StringBuilder("Hello,"); | |
b= new System.Text.StringBuilder(" World!"); | |
Swap<StringBuilder>(a,b); //it doesn't really swapping | |
RealSwap<StringBuilder>(ref a,ref b); | |
Console.WriteLine("{0}{1}",b,a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment