WizardStepCollection.CopyTo(WizardStepBase[], Int32) 메서드

정의

대상 배열의 지정한 인덱스부터 시작하여 WizardStepCollection 개체의 모든 항목을 WizardStepBase 개체의 호환되는 1차원 배열에 복사합니다.

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)

매개 변수

array
WizardStepBase[]

컬렉션에서 복사한 항목을 받는 WizardStepBase 개체의 0부터 시작하는 배열입니다.

index
Int32

복사된 항목을 받기 시작할 대상 배열 내의 위치입니다.

예제

다음 예제에서는 사용 하는 방법에 설명 합니다 CopyTo 복사 하는 메서드는 WizardStepBase 배열에 컬렉션에서 개체입니다. 표시할 배열을 다음 반복 합니다 ID 의 각 속성 WizardStepBase-파생 개체입니다. 예제를 WizardSteps 의 속성을 Wizard 컨트롤의 인스턴스가 WizardStepCollection 클래스.

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

설명

사용 된 CopyTo 컬렉션의 내용이 지정된 된 0부터 시작 배열에 복사 하는 방법입니다. 항목이 대상 배열의 지정한 인덱스부터 복사 됩니다. 배열에 항목을 항목에 액세스할 배열 구문을 사용할 수 있습니다는 WizardStepCollection 컬렉션입니다.

대신 사용할 수도 있습니다는 GetEnumerator 컬렉션의 항목에 액세스할 수 있는 열거자를 만드는 방법.

적용 대상

추가 정보