Skip to content

Instantly share code, notes, and snippets.

@kentaromiura
Created October 27, 2009 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentaromiura/219404 to your computer and use it in GitHub Desktop.
Save kentaromiura/219404 to your computer and use it in GitHub Desktop.
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