SiteMapNodeCollection.Item[Int32] Propiedad

Definición

Obtiene o establece el objeto SiteMapNode en el índice especificado de la colección.

public:
 virtual property System::Web::SiteMapNode ^ default[int] { System::Web::SiteMapNode ^ get(int index); void set(int index, System::Web::SiteMapNode ^ value); };
public virtual System.Web.SiteMapNode this[int index] { get; set; }
member this.Item(int) : System.Web.SiteMapNode with get, set
Default Public Overridable Property Item(index As Integer) As SiteMapNode

Parámetros

index
Int32

Índice del objeto SiteMapNode que se va a buscar.

Valor de propiedad

Objeto SiteMapNode que representa un elemento de SiteMapNodeCollection.

Excepciones

index es menor que cero.

o bien

index es mayor que Count.

El valor proporcionado al establecedor es null.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el Item[] indexador para recuperar un SiteMapNode objeto de la SiteMapNodeCollection colección. En este ejemplo, se quita un SiteMapNode objeto de su posición en el segundo elemento de la matriz interna mediante el Remove método y se anexa a la matriz con el Add método . Para insertar un SiteMapNode objeto en un índice específico, en lugar de anexarlo al final de la matriz, use el Insert método .


// 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 usar el Item[] indexador para iterar el contenido de una SiteMapNodeCollection colección o reemplazar el SiteMapNode objeto en un índice especificado.

Se aplica a

Consulte también