SiteMapNodeCollection.Remove(SiteMapNode) Metoda

Definice

Odebere zadaný SiteMapNode objekt z kolekce.

public:
 virtual void Remove(System::Web::SiteMapNode ^ value);
public virtual void Remove (System.Web.SiteMapNode value);
abstract member Remove : System.Web.SiteMapNode -> unit
override this.Remove : System.Web.SiteMapNode -> unit
Public Overridable Sub Remove (value As SiteMapNode)

Parametry

value
SiteMapNode

To SiteMapNode remove from the SiteMapNodeCollection.

Výjimky

value v kolekci neexistuje.

value je null.

Je SiteMapNodeCollection jen pro čtení.

-nebo- Má SiteMapNodeCollection pevnou velikost.

Příklady

Následující příklad kódu ukazuje, jak použít metodu Remove k odebrání SiteMapNode objektu z SiteMapNodeCollection kolekce a pak připojit SiteMapNode objekt na konec SiteMapNodeCollection použití Add metody. Pokud je jen pro SiteMapNodeCollection čtení, zachytí NotSupportedException se výjimka.


// Move a node from one spot in the list to another.
try {
    Response.Write("Original node order: <BR>");
    foreach (SiteMapNode node in nodes) {
        Response.Write( node.Title + "<BR>");
    }
    SiteMapNode aNode = nodes[1];

    Response.Write("Adding " + aNode.Title + " to the end of the collection.<BR>");
    nodes.Add(aNode);

    Response.Write("Removing " + aNode.Title + " at position 1. <BR>");
    nodes.Remove(nodes[1]);

    Response.Write("New node order: <BR>");
    foreach (SiteMapNode node in nodes) {
        Response.Write( node.Title + "<BR>");
    }
}
catch (NotSupportedException nse) {
    Response.Write("NotSupportedException caught.<BR>");
}

' Move a node from one spot in the list to another.
Try
    Response.Write("Original node order: <BR>")
    Dim node As SiteMapNode
    For Each node In nodes
        Response.Write( node.Title & "<BR>")
    Next

    Dim aNode As SiteMapNode = nodes(1)

    Response.Write("Adding " & aNode.Title & " to the end of the collection.<BR>")
    nodes.Add(aNode)

    Response.Write("Removing " & aNode.Title & " at position 1. <BR>")
    nodes.Remove(nodes(1))

    Response.Write("New node order: <BR>")

    For Each node In nodes
        Response.Write( node.Title & "<BR>")
    Next

Catch nse As NotSupportedException
    Response.Write("NotSupportedException caught.<BR>")
End Try

Poznámky

Můžete otestovat, jestli je kolekce jen pro čtení, a to tak, že SiteMapNodeCollection vlastnost zkontrolujete IsReadOnly .

Metoda Remove určuje rovnost voláním Object.Equals metody.

Platí pro

Viz také