Controls.OfType()泛型方法调用编译不 [英] Controls.OfType() generic method call not compiling

查看:256
本文介绍了Controls.OfType()泛型方法调用编译不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑这行code的:

List<HtmlGenericControl> listOfDivs = 
     this.clientGrid.Controls.OfType<HtmlGenericControl>()
                             .ToList<HtmlGenericControl>();

OfType&LT;&GT;(); 不被识别,假设由于使用缺少 指令。我试过使用System.Web.UI.ControlCollection; ,但这并没有解决问题。

The OfType<>(); isn't recognised, assuming due to a missing using directive. I've tried using System.Web.UI.ControlCollection;, but that didn't solve the problem.

这怎么能解决吗?

推荐答案

要使用 OfType&LT; T&GT; ,你需要一个使用System.Linq的; 指令在code文件。这也需要一个参考 System.Core.dll (以最典型的引用如果Visual Studio创建并非所有的默认应用程序2008 +)。

To use OfType<T>, you need a using System.Linq; directive in your code file. This also requires a reference to System.Core.dll (referenced in most typical if not all default applications created in Visual Studio 2008+).

这篇关于Controls.OfType()泛型方法调用编译不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆