SiteMapNodeCollection.Remove(SiteMapNode) Método

Definición

Quita el objeto SiteMapNode especificado de la colección.

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)

Parámetros

value
SiteMapNode

SiteMapNode que se va a quitar de SiteMapNodeCollection.

Excepciones

value no existe en la colección.

value es null.

SiteMapNodeCollection es de solo lectura.

o bien

SiteMapNodeCollection tiene un tamaño fijo.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el Remove método para quitar un SiteMapNode objeto de una SiteMapNodeCollection colección y, a continuación, anexar el SiteMapNode objeto al final del SiteMapNodeCollection mediante el Add método . Si es de SiteMapNodeCollection solo lectura, se detecta una NotSupportedException excepción.


// 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

Comentarios

Puede probar si una SiteMapNodeCollection colección es de solo lectura comprobando la IsReadOnly propiedad .

El Remove método determina la igualdad llamando al Object.Equals método .

Se aplica a

Consulte también