![](/img/trans.png)
[英]Solve “does not contain a definition for 'OfType'” error message?
[英]Error: System.Windows.Controls.UIElementCollection' does not contain a definition for 'OfType'
我想刪除WPF Canvas中的所有省略號。 我用這個方法:
public void clearCircle()
{
var circles = cvsSurface.Children.OfType<Ellipse>().ToList();
foreach (var c in circles)
{
cvsSurface.Children.Remove(c);
}
}
但是,我在.OfType上收到錯誤:
'System.Windows.Controls.UIElementCollection' does not contain a definition for 'OfType' and no extension method 'OfType' accepting a first argument of type 'System.Windows.Controls.UIElementCollection' could be found.
我需要包含一些東西嗎? 我正在使用.NET 4.5
我需要包含一些東西嗎?....
是的,你需要包括System.Linq
命名空間為解釋在這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.