Freigeben über


OperationFaultCollection.IndexOf-Methode

Sucht nach dem angegebenen OperationFault und gibt den nullbasierten Index des ersten Vorkommens in der Auflistung zurück.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public Function IndexOf ( _
    operationFaultMessage As OperationFault _
) As Integer
'Usage
Dim instance As OperationFaultCollection
Dim operationFaultMessage As OperationFault
Dim returnValue As Integer

returnValue = instance.IndexOf(operationFaultMessage)
public int IndexOf (
    OperationFault operationFaultMessage
)
public:
int IndexOf (
    OperationFault^ operationFaultMessage
)
public int IndexOf (
    OperationFault operationFaultMessage
)
public function IndexOf (
    operationFaultMessage : OperationFault
) : int

Parameter

  • operationFaultMessage
    Der OperationFault, nach dem in der Auflistung gesucht werden soll.

Rückgabewert

Eine 32-Bit-Ganzzahl mit Vorzeichen.

Beispiel

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
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.");
   }
}
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.
    get_PortTypes();
PortType myPortType = myPortTypeCollection.get_Item(0);
OperationCollection myOperationCollection = myPortType.
    get_Operations();
Operation myOperation = myOperationCollection.get_Item(0);
OperationFaultCollection myOperationFaultCollection = myOperation.
    get_Faults();
// Reverse the operation fault order.
if (myOperationFaultCollection.get_Count() > 1) {
    OperationFault myOperationFault = myOperationFaultCollection.
        get_Item(0);
    OperationFault myOperationFaultArray[] = new OperationFault[
        myOperationFaultCollection.get_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.get_Length(); i++) {
        myOperationFaultCollection.Remove(myOperationFaultArray.
            get_Item(i));
    }
    // Insert the operation faults in the reverse order.
    for (int i = 0, j = myOperationFaultArray.get_Length() - 1;
        i < myOperationFaultArray.get_Length(); i++, j--) {
        myOperationFaultCollection.Insert(i, myOperationFaultArray.
            get_Item(j));
    }
    if (myOperationFaultCollection.Contains(myOperationFault) 
        && myOperationFaultCollection.IndexOf(myOperationFault)
        == myOperationFaultCollection.get_Count() - 1) {
        Console.WriteLine("Succeeded in reversing the operation "
            + "faults.");
    }
    else {
        Console.WriteLine("Error while reversing the faults.");
    }
}

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

OperationFaultCollection-Klasse
OperationFaultCollection-Member
System.Web.Services.Description-Namespace