Created
February 16, 2010 18:47
-
-
Save hoganlong/305787 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.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