Skip to content

Instantly share code, notes, and snippets.

@hoganlong
Created February 16, 2010 18:47
Show Gist options
  • Save hoganlong/305787 to your computer and use it in GitHub Desktop.
Save hoganlong/305787 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace testalot
{
public class testa
{
override public string ToString()
{
return ("testa tostring()");
}
}
public class testb
{
new public string ToString()
{
return ("testb tostring()");
}
}
public class testc
{
}
public static class ToStringExpander
{
public static string ToString(this testc x)
{
return "testc extender.";
}
public static string MyToString(this Object x)
{
return x.ToString()+" extended.";
}
public static string MyToString(this testc x)
{
return "testc extended.";
}
}
class Program
{
static void Main(string[] args)
{
testa t1 = new testa();
Console.WriteLine(t1.ToString());
Console.WriteLine(((Object)t1).ToString());
Console.WriteLine(t1.MyToString());
Console.WriteLine(((Object)t1).MyToString());
Console.WriteLine();
testb t2 = new testb();
Console.WriteLine(t2.ToString());
Console.WriteLine(((Object)t2).ToString());
Console.WriteLine(t2.MyToString());
Console.WriteLine(((Object)t2).MyToString());
Console.WriteLine();
testc t3 = new testc();
Console.WriteLine(t3.ToString());
Console.WriteLine(ToStringExpander.ToString(t3));
Console.WriteLine(t3.MyToString());
Console.WriteLine(((Object)t3).MyToString());
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment