OperationFaultCollection.CopyTo(OperationFault[], Int32) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
OperationFaultCollection 全体を互換性のある OperationFault 型の 1 次元配列にコピーします。コピーは、コピー先の配列の、指定した 0 から始まるインデックス番号から開始します。
public:
void CopyTo(cli::array <System::Web::Services::Description::OperationFault ^> ^ array, int index);
public void CopyTo (System.Web.Services.Description.OperationFault[] array, int index);
member this.CopyTo : System.Web.Services.Description.OperationFault[] * int -> unit
Public Sub CopyTo (array As OperationFault(), index As Integer)
パラメーター
- array
- OperationFault[]
コピー アクションのコピー先として使用する OperationFault 型の配列。
- index
- Int32
コピーされたコレクションの貼り付け開始位置を示す、0 から始まるインデックス番号。
例
PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes;
PortType^ myPortType = myPortTypeCollection[ 0 ];
OperationCollection^ myOperationCollection = myPortType->Operations;
Operation^ myOperation = myOperationCollection[ 0 ];
OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults;
// Reverse the operation fault order.
if ( myOperationFaultCollection->Count > 1 )
{
OperationFault^ myOperationFault = myOperationFaultCollection[ 0 ];
array<OperationFault^>^myOperationFaultArray = gcnew array<OperationFault^>(myOperationFaultCollection->Count);
// Copy the operation fault to a temporary array.
myOperationFaultCollection->CopyTo( myOperationFaultArray, 0 );
// Remove all the operation faults from the collection.
for ( int i = 0; i < myOperationFaultArray->Length; i++ )
myOperationFaultCollection->Remove( myOperationFaultArray[ i ] );
// Insert the operation faults in the reverse order.
for ( int i = 0,j = (myOperationFaultArray->Length - 1); i < myOperationFaultArray->Length; i++,j-- )
myOperationFaultCollection->Insert( i, myOperationFaultArray[ j ] );
if ( myOperationFaultCollection->Contains( myOperationFault ) && (myOperationFaultCollection->IndexOf( myOperationFault ) == myOperationFaultCollection->Count - 1) )
Console::WriteLine( "Succeeded in reversing the operation faults." );
else
Console::WriteLine( "Error while reversing the faults." );
}
PortTypeCollection myPortTypeCollection =
myServiceDescription.PortTypes;
PortType myPortType = myPortTypeCollection[0];
OperationCollection myOperationCollection = myPortType.Operations;
Operation myOperation = myOperationCollection[0];
OperationFaultCollection myOperationFaultCollection =
myOperation.Faults;
// Reverse the operation fault order.
if(myOperationFaultCollection.Count > 1)
{
OperationFault myOperationFault = myOperationFaultCollection[0];
OperationFault[] myOperationFaultArray =
new OperationFault[myOperationFaultCollection.Count];
// Copy the operation faults to a temporary array.
myOperationFaultCollection.CopyTo(myOperationFaultArray, 0);
// Remove all the operation faults from the collection.
for(int i = 0; i < myOperationFaultArray.Length; i++)
{
myOperationFaultCollection.Remove(myOperationFaultArray[i]);
}
// Insert the operation faults in the reverse order.
for(int i = 0, j = (myOperationFaultArray.Length - 1);
i < myOperationFaultArray.Length; i++, j--)
{
myOperationFaultCollection.Insert(
i, myOperationFaultArray[j]);
}
if ( myOperationFaultCollection.Contains(myOperationFault) &&
(myOperationFaultCollection.IndexOf(myOperationFault)
== myOperationFaultCollection.Count-1))
{
Console.WriteLine(
"Succeeded in reversing the operation faults.");
}
else
{
Console.WriteLine("Error while reversing the faults.");
}
}
Dim myPortTypeCollection As PortTypeCollection = _
myServiceDescription.PortTypes
Dim myPortType As PortType = myPortTypeCollection(0)
Dim myOperationCollection As OperationCollection = _
myPortType.Operations
Dim myOperation As Operation = myOperationCollection(0)
Dim myOperationFaultCollection As OperationFaultCollection = _
myOperation.Faults
' Reverse the operation fault order.
If myOperationFaultCollection.Count > 1 Then
Dim myOperationFault As OperationFault = _
myOperationFaultCollection(0)
Dim myOperationFaultArray(myOperationFaultCollection.Count -1 ) _
As OperationFault
' Copy the operation faults to a temporary array.
myOperationFaultCollection.CopyTo(myOperationFaultArray, 0)
' Remove all the operation faults from the collection.
Dim i As Integer
For i = 0 To myOperationFaultArray.Length - 1
myOperationFaultCollection.Remove(myOperationFaultArray(i))
Next i
' Insert the operation faults in the reverse order.
Dim j As Integer = myOperationFaultArray.Length - 1
i = 0
While i < myOperationFaultArray.Length
myOperationFaultCollection.Insert(i, myOperationFaultArray(j))
i += 1
j -= 1
End While
If myOperationFaultCollection.Contains(myOperationFault) And _
myOperationFaultCollection.IndexOf(myOperationFault) = _
myOperationFaultCollection.Count - 1 Then
Console.WriteLine("Succeeded in reversing the operation faults.")
Else
Console.WriteLine("Error while reversing the faults.")
End If
End If
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET