fork(7) download
  1. using System;
  2.  
  3. interface IWrapper
  4. {
  5. void Print();
  6. }
  7.  
  8. class Wrapper<T> : IWrapper
  9. {
  10. T t;
  11. public Wrapper(T t) { this.t = t; }
  12. public void Print() { Console.WriteLine("Wrapper <" + typeof(T).Name + ">"); }
  13. }
  14.  
  15. class Program
  16. {
  17. static public void Print<T>(T t)
  18. {
  19. if (t is IWrapper)
  20. {
  21. ((IWrapper)t).Print();
  22. }
  23. else
  24. {
  25. Print(new Wrapper<T>(t));
  26. }
  27. }
  28.  
  29. static void Main(string[] args)
  30. {
  31. Print(0);
  32. }
  33. }
  34.  
Success #stdin #stdout 0.02s 33808KB
stdin
Standard input is empty
stdout
Wrapper <Int32>