SiteMapNodeCollection.Contains Method (SiteMapNode)
.NET Framework (current version)
Determines whether the collection contains a specific SiteMapNode object.
Assembly: System.Web (in System.Web.dll)
Parameters
- value
-
Type:
System.Web.SiteMapNode
The SiteMapNode to locate in the SiteMapNodeCollection.
Return Value
Type: System.Booleantrue if the SiteMapNodeCollection contains the specified SiteMapNode; otherwise, false.
The Contains method determines equality by calling the Object.Equals method.
The following code example demonstrates how to use the Contains and IndexOf methods of the SiteMapNodeCollection class. The code checks two providers, AspNetXmlSiteMapProvider and MyXmlSiteMapProvider, for child nodes of the root node that are duplicates.
Dim providername1 As String = "xAspNetXmlSiteMapProvider" Dim providername2 As String = "MyXmlSiteMapProvider" Dim providers As SiteMapProviderCollection = SiteMap.Providers If Not (providers(providername1) Is Nothing) AndAlso Not (providers(providername2) Is Nothing) Then Dim provider1 As SiteMapProvider = providers(providername1) Dim provider2 As SiteMapProvider = providers(providername2) Dim collection1 As SiteMapNodeCollection = provider1.RootNode.ChildNodes Dim collection2 As SiteMapNodeCollection = provider2.RootNode.ChildNodes Dim matches As Integer = 0 Dim node As SiteMapNode For Each node In collection1 If collection2.Contains(node) Then Response.Write("Match found at " & _ providername1 & ", index = " & _ collection1.IndexOf(node) & " with " & _ providername2 & ", index = " & _ collection2.IndexOf(node) & ".<br />") matches += 1 End If Next node Response.Write("Number of matches found = " & _ matches.ToString() + ".") Else Response.Write(providername1 & " or " & _ providername2 & " not found.") End If
.NET Framework
Available since 2.0
Available since 2.0
Show: