SoapHeaderCollection.IndexOf(SoapHeader) Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Determina el índice de SoapHeader en SoapHeaderCollection.
public:
int IndexOf(System::Web::Services::Protocols::SoapHeader ^ header);
public int IndexOf (System.Web.Services.Protocols.SoapHeader header);
member this.IndexOf : System.Web.Services.Protocols.SoapHeader -> int
Public Function IndexOf (header As SoapHeader) As Integer
Parámetros
- header
- SoapHeader
Objeto SoapHeader que se va a buscar en la interfaz SoapHeaderCollection.
Devoluciones
Índice del parámetro header
, si se encuentra en SoapHeaderCollection; en caso contrario, -1.
Ejemplos
// Check to see whether the collection contains mySecondSoapHeader.
if ( mySoapHeaderCollection->Contains( mySecondSoapHeader ) )
{
// Get the index of mySecondSoapHeader from the collection.
Console::WriteLine( "Index of mySecondSoapHeader: {0}", mySoapHeaderCollection->IndexOf( mySecondSoapHeader ) );
// Get the SoapHeader from the collection.
MySoapHeader^ mySoapHeader1 = dynamic_cast<MySoapHeader^>(mySoapHeaderCollection[ mySoapHeaderCollection->IndexOf( mySecondSoapHeader ) ]);
Console::WriteLine( "SoapHeader retrieved from the collection: {0}", mySoapHeader1 );
// Remove a SoapHeader from the collection.
mySoapHeaderCollection->Remove( mySoapHeader1 );
Console::WriteLine( "Number of items after removal: {0}", mySoapHeaderCollection->Count );
}
else
Console::WriteLine( "mySoapHeaderCollection does not contain mySecondSoapHeader." );
// Check to see whether the collection contains mySecondSoapHeader.
if(mySoapHeaderCollection.Contains(mySecondSoapHeader))
{
// Get the index of mySecondSoapHeader from the collection.
Console.WriteLine("Index of mySecondSoapHeader: " +
mySoapHeaderCollection.IndexOf(mySecondSoapHeader));
// Get the SoapHeader from the collection.
MySoapHeader mySoapHeader1 = (MySoapHeader)mySoapHeaderCollection
[mySoapHeaderCollection.IndexOf(mySecondSoapHeader)];
Console.WriteLine("SoapHeader retrieved from the collection: "
+ mySoapHeader1);
// Remove a SoapHeader from the collection.
mySoapHeaderCollection.Remove(mySoapHeader1);
Console.WriteLine("Number of items after removal: {0}",
mySoapHeaderCollection.Count);
}
else
Console.WriteLine(
"mySoapHeaderCollection does not contain mySecondSoapHeader.");
' Check to see whether the collection contains mySecondSoapHeader.
If mySoapHeaderCollection.Contains(mySecondSoapHeader) Then
' Get the index of mySecondSoapHeader from the collection.
Console.WriteLine("Index of mySecondSoapHeader: " & _
mySoapHeaderCollection.IndexOf(mySecondSoapHeader).ToString())
' Get the SoapHeader from the collection.
Dim mySoapHeader1 As MySoapHeader = CType(mySoapHeaderCollection( _
mySoapHeaderCollection.IndexOf(mySecondSoapHeader)), _
MySoapHeader)
Console.WriteLine("SoapHeader retrieved from the collection: " _
& mySoapHeader1.ToString())
' Remove a SoapHeader from the collection.
mySoapHeaderCollection.Remove(mySoapHeader1)
Console.WriteLine("Number of items after removal: {0}", _
& mySoapHeaderCollection.Count)
Else
Console.WriteLine( _
"mySoapHeaderCollection does not contain mySecondSoapHeader.")
End If
Se aplica a
Consulte también
Colaborar con nosotros en GitHub
El origen de este contenido se puede encontrar en GitHub, donde también puede crear y revisar problemas y solicitudes de incorporación de cambios. Para más información, consulte nuestra guía para colaboradores.