-1

如何SiteMap.RootNode.ChildNames在一行中找到标题的值 equel 'test'?我不写 linq 它不起作用。

   protected SiteMapNodeCollection getParentNodeTitle()
   {
        SiteMap.RootNode.ChildNames            
   }
4

1 回答 1

0

这应该可以解决问题:

var mySiteMap = new SiteMap();
/* Lots of code for populating your SiteMap here */

var nodeTitledTest = mySiteMap.RootNode.ChildNodes.Where(x => x.Title == "test").FirstOrDefault();

这将返回标题等于“test”的第一个节点,如果找不到这样的节点,则返回 null。

于 2013-01-22T10:08:08.660 回答