Re: How do I use Generics with interfaces?



MrNobody wrote:



"AlexS" wrote:

Is that what you are talking about?


close,

like this:

class MyObject : IMyInterface { ... }
....
public void doSomething(List<IMyInterface> list) { ... }
....
List<MyObject> list = new List<MyObject>();
doSomething(list);

Hi,

So we've already discussed that this isn't possible, due to the lack of
support for generic covariance. But array covariance *is* supported, have
you had any luck trying this?

--
Tom Spink
University of Edinburgh
.



Relevant Pages

  • RE: MoveNext() method not covered by unit testing?
    ... public void ItemsConstructorTest() ... coverage. ... Microsoft Online Community Support ... nature are best handled working with a dedicated Microsoft Support Engineer ...
    (microsoft.public.vsnet.enterprise.tools)
  • RE: Delegates/events
    ... public void OnMyEvent ... public class Second ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.csharp)
  • F2k3 Translation - UML 2 Test Profile Example
    ... although I don't know what assertTrue does or how to handle the throw. ... public void addDifferentMoney() ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Using overload to implement the equivalent of a switch
    ... public abstract void doSomething(Object anObject); ... public void doSomething{ ... AbstractBase reference = new ResponsibleChild; ... Java does not support this concept at the language level. ...
    (comp.lang.java.programmer)