Tag: oftype

在C#中使用OfType过滤类型的对象

我有一个基类Base,以及inheritance自它的A / B类。 public class Base { int x; } public class A : Base { int y; } public class B : Base { int z; } 我尝试使用OfType来过滤我需要的唯一对象,如下所示: public static void RunSnippet() { Base xbase; A a; B b; IEnumerable list = new List() {xbase, a, b}; Base f = list.OfType; // I need […]