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: 
You want "all Classes that implement the IMatcher Interface". But in fact, there is no `IMatchter` interface. There is only `IMatcher<T,U>`, which is to be precise not an interface. This notation is a shortcut, from which the compiler will be able to create a lot of different interfaces like `IMatcher<string,string>`, `IMatcher<string,DateTime>`, etc.

`IMatcher<string,string>` is a completely different type than `IMatcher<string,DateTime>`, hence `X1` and `X2` don't have a common base type! You need a common non-generic base type if you want to do that. It might look like this:

```
public interface IMatcher
{
    bool Match(object first, object second);
}

public interface IMatcher<T, U> : IMatcher
{
   bool Match(T first, U Second);
}

class X1: IMatcher<string, string>
{

   public bool Match(object first, object second)
   {
       return Match((string) first, (string) second);
   }

   public bool Match(string first, string second)
   {
       return true;
   }
} 

class X2: IMatcher<string, DateTime>
{
public bool Match(object first, object second)
   {
       return Match((string) first, (DateTime) second);
   }

   public bool Match(string first, DateTime second)
   {
       return true;
   }
}

```

Then you can store instances of `X1` and `X2` in common list, but you lose the advantages of generics. You have to decide if this approach makes sense in your case.
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
     }
}

```