title: What is the workaround for the missing C# generic wildcards <?>
body: <p>In Java I can declare a method like: <code>public boolean doSth(Cache&lt;?&gt; cache, CacheItem item){...}</code></p>
  
  <pre><code>public interface Cache&lt;T&gt; {
      public boolean Contains(T item);
  }
  
  public class CacheFilePath implements Cache&lt;FilePathItem&gt; {
      @Override
      public boolean Contains(FilePathItem item) {
          return false; // TODO
      }
  }
  
  public class ItemHandler {
  
      public boolean doSth(Cache&lt;?&gt; cache, CacheItem item){
          if(cache instanceof CacheHostName &amp;&amp; item instanceof HostNameItem){
              CacheHostName c = (CacheHostName) cache;
              HostNameItem i = (HostNameItem) item;
              return check(c, i);
          }
          else if(cache instanceof CacheFilePath &amp;&amp; item instanceof FilePathItem){
              CacheFilePath c = (CacheFilePath) cache;
              FilePathItem i = (FilePathItem) item;
              return check(c, i);
          }
          throw new RuntimeException("Invalid arguments  !!!");
      }
  
      private boolean check(Cache&lt;HostNameItem&gt; cache, HostNameItem item){
          return cache.Contains(item);
      }
  
      private boolean check(Cache&lt;FilePathItem&gt; cache, FilePathItem item){
          return cache.Contains(item);
      }
  }
  </code></pre>
  
  <p>How can I declare such a method in C#?</p>