开发者

Ambiguous Reference In TreeView Control

开发者 https://www.devze.com 2023-01-11 17:59 出处:网络
I am trying to run a web application with a TreeView control in Visual Studio 2008 and I get t开发者_开发技巧his error:

I am trying to run a web application with a TreeView control in Visual Studio 2008 and I get t开发者_开发技巧his error:

'TreeNodeCollection' is an ambiguous reference between 'System.Web.UI.WebControls.TreeNodeCollection' and 'Microsoft.Web.UI.WebControls.TreeNodeCollection'

Can anyone help me?


Well if you know which namespace is the one you want to be using for the node collection, just put the full namespace in front of the TreeNodeCollection object, like such:

Microsoft.Web.UI.Controls.TreeNodeCollection myNodeCollection = new Microsoft.Web.UI.Controls.TreeNodeCollection();


You have references (usings) to two libraries "System.Web.UI.WebControls" and "Microsoft.Web.UI.WebControls". Each of them has class TreeNodeCollection. To resolve problem you have to specify full reference in code:

System.Web.UI.WebControls.TreeNodeCollection collection = null;

Or you can specify aliases to this libraries:

using MWC = Microsoft.Web.UI.WebControls;
using SWC = System.Web.UI.WebControls;

SWC.TreeNodeCollection collection = null;
0

精彩评论

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

关注公众号