WizardStepCollection.CopyTo(WizardStepBase[], Int32) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Kopierar alla objekt från en WizardStepCollection samling till en kompatibel endimensionell matris med WizardStepBase objekt, med början vid det angivna indexet i målmatrisen.
public:
void CopyTo(cli::array <System::Web::UI::WebControls::WizardStepBase ^> ^ array, int index);
public void CopyTo(System.Web.UI.WebControls.WizardStepBase[] array, int index);
member this.CopyTo : System.Web.UI.WebControls.WizardStepBase[] * int -> unit
Public Sub CopyTo (array As WizardStepBase(), index As Integer)
Parametrar
- array
- WizardStepBase[]
En nollbaserad matris med WizardStepBase objekt som tar emot de objekt som kopierats från samlingen.
- index
- Int32
Positionen i målmatrisen där matrisen börjar ta emot de kopierade objekten.
Exempel
I följande exempel visas hur du använder CopyTo metoden för att kopiera objekten WizardStepBase från samlingen till en matris. Matrisen itereras sedan igenom för att visa ID egenskapen för varje WizardStepBase-derived-objekt. Observera att i exemplet WizardSteps är kontrollens Wizard egenskap en instans av WizardStepCollection klassen.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Declare an array of WizardStepBase objects.
WizardStepBase[] stepArray = new WizardStepBase[Wizard1.WizardSteps.Count];
// Use the CopyTo method to copy the WizardStep items
// of the Wizard control into the array.
Wizard1.WizardSteps.CopyTo(stepArray, 0);
// Display the WizardStep items.
Message.Text = "The WizardStepBase items of the Wizard1 control are: <br/><br/>";
for (int i = 0; i < stepArray.Length; i++)
{
Message.Text += stepArray[i].ID + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Wizard id="Wizard1"
runat="server" >
<WizardSteps>
<asp:WizardStep id="WizardStep1"
runat="server"
title="Step 1">
</asp:WizardStep>
<asp:WizardStep id="WizardStep2"
runat="server"
title="Step 2">
</asp:WizardStep>
<asp:WizardStep id="WizardStep3"
runat="server"
title="Step 3">
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<b>WizardStepCollection CopyTo Example</b>
</HeaderTemplate>
</asp:Wizard>
<asp:label id="Message"
runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Declare an array of WizardStepBase objects.
Dim stepArray(Wizard1.WizardSteps.Count - 1) As WizardStep
' Use the CopyTo method to copy the WizardStep items
' of the Wizard control into the array.
Wizard1.WizardSteps.CopyTo(stepArray, 0)
' Display the WizardStep items.
Message.Text = "The WizardStepBase items of the Wizard1 control are: <br/><br/>"
For i As Integer = 0 To stepArray.Length - 1
Message.Text &= stepArray(i).ID & "<br />"
Next
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Wizard id="Wizard1"
runat="server" >
<WizardSteps>
<asp:WizardStep id="WizardStep1"
runat="server"
title="Step 1">
</asp:WizardStep>
<asp:WizardStep id="WizardStep2"
runat="server"
title="Step 2">
</asp:WizardStep>
<asp:WizardStep id="WizardStep3"
runat="server"
title="Step 3">
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<b>WizardStepCollection CopyTo Example</b>
</HeaderTemplate>
</asp:Wizard>
<asp:label id="Message"
runat="server"/>
</form>
</body>
</html>
Kommentarer
CopyTo Använd metoden för att kopiera innehållet i samlingen till den angivna nollbaserade matrisen. Objekt kopieras från och med det angivna indexet för målmatrisen. När objekten finns i en matris kan du använda matrissyntax för att komma åt objekten WizardStepCollection i samlingen.
Alternativt kan du också använda GetEnumerator metoden för att skapa en uppräknare som kan användas för att komma åt objekten i samlingen.