WizardStepCollection.CopyTo(WizardStepBase[], Int32) Yöntem

Tanım

Bir koleksiyondaki tüm öğeleri hedef dizideki WizardStepBase belirtilen dizinden WizardStepCollection başlayarak uyumlu bir tek boyutlu nesne dizisine kopyalar.

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)

Parametreler

array
WizardStepBase[]

Koleksiyondan kopyalanan öğeleri alan sıfır tabanlı bir nesne dizisi WizardStepBase .

index
Int32

Dizinin kopyalanan öğeleri almaya başladığı hedef dizideki konum.

Örnekler

Aşağıdaki örnekte, koleksiyondaki nesneleri diziye kopyalamak WizardStepBase için yönteminin nasıl kullanılacağı CopyTo gösterilmektedir. Ardından dizi, türetilmiş her WizardStepBasenesnenin ID özelliğini görüntülemek için üzerinden yinelenir. Örnekte, denetimin WizardSteps özelliğinin Wizard sınıfın WizardStepCollection bir örneği olduğunu unutmayın.

<%@ 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>

Açıklamalar

Koleksiyonun CopyTo içeriğini belirtilen sıfır tabanlı diziye kopyalamak için yöntemini kullanın. Öğeler hedef dizinin belirtilen dizininden başlayarak kopyalanır. Öğeler bir dizide olduktan sonra, koleksiyondaki öğelere erişmek için dizi söz dizimini WizardStepCollection kullanabilirsiniz.

Alternatif olarak, yöntemini kullanarak koleksiyondaki GetEnumerator öğelere erişmek için kullanılabilecek bir numaralandırıcı oluşturabilirsiniz.

Şunlara uygulanır

Ayrıca bkz.