【发布时间】:2018-03-16 15:50:58
【问题描述】:
在我的 WPF 应用程序中,我有以下行:
var windowList = Application.Current.Windows.OfType<Window>().ToList();
这将返回 2 个结果。这些结果有以下几种:
Microsoft.Crm.UnifiedServiceDesk.DesktopSystem.Windows.Window
我只希望返回第二个结果。但是,由于结果 #1 继承了System.Windows.Window,因此它包含在结果中。
有没有办法限制OfType<T>() 函数不返回继承的类,还是我必须以其他方式完成?
【问题讨论】:
标签: c# wpf linq inheritance oftype