次の方法で共有


PortTypeCollection.CopyTo メソッド

PortTypeCollection 全体を 1 次元の PortType 型の配列にコピーします。コピーは、コピー先の配列の指定した 0 から始まるインデックス番号から開始します。

Public Sub CopyTo( _
   ByVal array() As PortType, _   ByVal index As Integer _)
[C#]
public void CopyTo(PortType[] array,intindex);
[C++]
public: void CopyTo(PortType* array[],intindex);
[JScript]
public function CopyTo(
   array : PortType[],index : int);

パラメータ

  • array
    コピー アクションのコピー先として使用する PortType 型の配列。
  • index
    コピーされたコレクションの貼り付け開始位置を示す、0 から始まるインデックス番号。

使用例

 
Dim myPortTypeCollection As PortTypeCollection

Dim myServiceDescription As ServiceDescription = _
   ServiceDescription.Read("MathService_VB.wsdl")
myPortTypeCollection = myServiceDescription.PortTypes
Dim noOfPortTypes As Integer = myServiceDescription.PortTypes.Count
Console.WriteLine( _
   ControlChars.NewLine + "Total number of PortTypes: " & _
   myServiceDescription.PortTypes.Count.ToString())

' Copy the collection into an array.
Dim myPortTypeArray(noOfPortTypes-1) As PortType
myPortTypeCollection.CopyTo(myPortTypeArray, 0)

' Display names of all PortTypes.
Dim i As Integer
For i = 0 To noOfPortTypes - 1
   Console.WriteLine("PortType Name: " + myPortTypeArray(i).Name)
Next i
myServiceDescription.Write("MathService_New.wsdl")

[C#] 
PortTypeCollection myPortTypeCollection;

ServiceDescription myServiceDescription = 
   ServiceDescription.Read("MathService_CS.wsdl");

myPortTypeCollection = myServiceDescription.PortTypes;
int noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: " 
   + myServiceDescription.PortTypes.Count);

// Copy the collection into an array.
 PortType[] myPortTypeArray = new PortType[noOfPortTypes];
 myPortTypeCollection.CopyTo(myPortTypeArray, 0);

// Display names of all PortTypes.
 for(int i = 0; i < noOfPortTypes; i++)
    Console.WriteLine("PortType name: " + myPortTypeArray[i].Name);
 myServiceDescription.Write("MathService_New.wsdl");

[C++] 
PortTypeCollection* myPortTypeCollection;

ServiceDescription* myServiceDescription = 
   ServiceDescription::Read(S"MathService_CS.wsdl");

myPortTypeCollection = myServiceDescription->PortTypes;
int noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine(S"\nTotal number of PortTypes: {0}", __box(myServiceDescription->PortTypes->Count));

// Copy the collection into an array.
PortType* myPortTypeArray[] = new PortType*[noOfPortTypes];
myPortTypeCollection->CopyTo(myPortTypeArray, 0);

// Display names of all PortTypes.
for(int i = 0; i < noOfPortTypes; i++)
   Console::WriteLine(S"PortType name: {0}", myPortTypeArray[i]->Name);
myServiceDescription->Write(S"MathService_New.wsdl");

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

PortTypeCollection クラス | PortTypeCollection メンバ | System.Web.Services.Description 名前空間