(inheritance) problem with generic



I try to test the interface implemented by a generic with the simple test
below.
What puzzle me is that all 4 test return false!
Any idea why is that and how to find the IList interface from the type?

-------------
using System;
using System.Collections;
using System.Collections.Generic;

// csc /nologo Class1.cs && Class1
public class Class1
{
public static void Main()
{
List<string> ls = new List<string>();
if(ls is IList)
{
Console.WriteLine("is IList(1): " +
ls.GetType().IsSubclassOf(typeof(IList)));
Console.WriteLine("is IList(2): " +
ls.GetType().IsAssignableFrom(typeof(IList)));
Console.WriteLine("is IList(3): " +
ls.GetType().IsInstanceOfType(typeof(IList)));
Console.WriteLine("is IList(4): " +
ls.GetType().IsDefined(typeof(IList), true));
}
}
}


.



Relevant Pages

  • OLEAutomation Interop with object []
    ... There doesn't seem to be an obvious way to have an interface ... public class Class1: IMyInterface ... dim parm ... obj.Connect parm ...
    (microsoft.public.dotnet.framework.interop)
  • [OOP] attributes and interface both mandatory
    ... public MyAttribute: Attribute ... public interface MyInterface ... public class class1: MyInteface ... public class class1: MyInterface ...
    (microsoft.public.dotnet.framework)
  • Re: Implementing Interfaces in C#
    ... "Class1 does not implement interface member ABC.DoSomething" ... public interface ABC ... public class Class1: ABC ... > VB.net on the other hand generates a compile error if a method is not ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: (inheritance) problem with generic
    ... > What puzzle me is that all 4 test return false! ... > Any idea why is that and how to find the IList interface from the type? ... Prev by Date: ...
    (microsoft.public.dotnet.framework)
  • Re: Argggh... Killed by death ray with MR?
    ... this is not inconsistent. ... In puzzle games(i.e. ... the complexity of the interface, in which case it is valid to point out ... shield, that's what I'd expect and I think most other people would ...
    (rec.games.roguelike.nethack)

Loading