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
精彩评论