(inheritance) problem with generic
- From: "Lloyd Dupont" <net.galador@ld>
- Date: Wed, 15 Jun 2005 11:49:07 +1000
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));
}
}
}
.
- Follow-Ups:
- Re: (inheritance) problem with generic
- From: Mattias Sjögren
- Re: (inheritance) problem with generic
- From: Lau Lei Cheong
- Re: (inheritance) problem with generic
- Prev by Date: Re: Programmatically producing certificate in .pfx format in .NET
- Next by Date: Re: (inheritance) problem with generic
- Previous by thread: FileSystemWatcher network problem
- Next by thread: Re: (inheritance) problem with generic
- Index(es):
Relevant Pages
|
Loading