fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. interface IA {
  5. Object vObj{get;}
  6. }
  7. class A<T> : IA where T : struct {
  8. public T v;
  9. public A(T v) { this.v = v; }
  10. public Object vObj { get { return v; } }
  11. }
  12. class B{
  13. public List<IA> ls = new List<IA>();
  14. public B(){
  15. ls.Add(new A<int>(10));
  16. ls.Add(new A<double>(1.5));
  17. }
  18. }
  19. class Test{
  20. static void Main(string[] args){
  21. B b = new B();
  22. foreach (IA a in b.ls){
  23. Console.WriteLine(a.GetType() + ":" + a.vObj);
  24. }
  25. }
  26. }
Success #stdin #stdout 0.03s 37072KB
stdin
Standard input is empty
stdout
A`1[System.Int32]:10
A`1[System.Double]:1.5