开发者

Controls.OfType() generic method call not compiling

Consider have this line of code:

List<HtmlGenericControl> listOfDivs = 
     this.clientGrid.Controls.OfType<HtmlGenericControl>()
                             .T开发者_如何学PythonoList<HtmlGenericControl>();

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.

How can this be fixed?


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+).


Just to add a little to Anthony's answer. if you do a search on MSDN for OfType you get the Enumerable.OfType<TResult> Method as the first result

It will show you the Namespace and Assembly

Controls.OfType() generic method call not compiling

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜