1

Trying to understand pattern matching for Generics in C#. Let's say I have the following:

public interface IPerson {}

public class Person : IPerson {}

And now try pattern match, result2 returns false:

List<IPerson> peeps1 = new List<IPerson>();
var result1 = peeps1 is List<IPerson>;  // true
List<Person> peeps2 = new List<Person>();
var result2 = peeps2 is List<IPerson>;  // false

What is needed to make result2 a true statement? Any help is appreciated.

shaggygi
  • 11
  • 1

0 Answers0