Question: I got the following Problem:

Is there a way to get all Classes that implement the IMatcher Interface in a List ?
The Generics T U cannot be set as Unknown. In Java we can use the "?", but in C# there is no Operator for this.

```
public interface IMatcher<T, U>
{
}

class X1: IMatcher<string, string>
{
} 

class X2: IMatcher<string, DateTime>
{
}

class Program
{
    static void Main(string[] args)
    {
        List<IMatcher<>> l = new List(); //NOT WORKING
        l.add(new X1());
        l.add(new X2());
    }

}   

```

Answer: 
`IMatcher<string, string>` and `IMatcher<string, DateTime>` are as far as the compiler is concerned two different types. So there are no way to store X1 and X2 in the same list. Consider for example if the interface had a property `U MyProperty {get;set;}`, and you wanted to do `l[0].MyProperty` what should the type be? a string or a DateTime? Since it could be either it is simply not allowed.

One way to provide a workaround is to add a non-generic common interface, `public interface IMatcher {}` that `IMatcher<T, U>` derives from. Or a `IMatcher<T>`, since both X1 and X2 have the same T-parameter type.

You could possibly also use a `List<object>`, but then you lose the static typing. There is also `dynamic`, but that completely turns of type checking.
Consider using the `dynamic` keyword if the generic types are **not** value types

Here is a simple example with a generic interface, 3 concrete implementations and a list to store them:

```
public interface IVector<out T>
{
    T[] Data { get; }
}

public class StrVector : IVector<string>
{
    public StrVector(params string[] data)
    {
        Data=data;
    }

    public string[] Data { get; }
}
public class IntVector : IVector<int>
{
    public IntVector(params int[] data)
    {
        Data=data;
    }

    public int[] Data { get; }
}
public class FileVector : IVector<FileInfo>
{
    public FileVector(params FileInfo[] data)
    {
        Data=data;
    }

    public FileInfo[] Data { get; }
}

static class Program
{
    static void Main(string[] args)
    {
        var dynList = new List<IVector<dynamic>>();
        dynList.Add(new StrVector("a", "b", "c"));
        dynList.Add(new FileVector(new FileInfo("abc.txt"), new FileInfo("data.xml")));
        //dynList.Add(new IntVector(0, 5, 15, 80)); // Error: int is value type
        foreach (var item in dynList)
        {
            Console.WriteLine(string.Join(",", item.Data));
        }           
        //a,b,c
        //abc.txt,data.xml
     }
}

```