Freigeben über


SoapHeaderCollection.Remove-Methode

Entfernt das erste Vorkommen eines bestimmten SoapHeader in der SoapHeaderCollection.

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

Syntax

'Declaration
Public Sub Remove ( _
    header As SoapHeader _
)
'Usage
Dim instance As SoapHeaderCollection
Dim header As SoapHeader

instance.Remove(header)
public void Remove (
    SoapHeader header
)
public:
void Remove (
    SoapHeader^ header
)
public void Remove (
    SoapHeader header
)
public function Remove (
    header : SoapHeader
)

Parameter

Hinweise

Die SoapHeader-Elemente, die an die Stelle des entfernten SoapHeader rücken, um die freie Stelle zu schließen.

Beispiel

' 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
// 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 ) )
{
   // 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.
        get_Item(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}", 
        System.Convert.ToString(mySoapHeaderCollection.get_Count()));
}
else {
    Console.WriteLine("mySoapHeaderCollection does not contain "
        + "mySecondSoapHeader.");
}

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, 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

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

SoapHeaderCollection-Klasse
SoapHeaderCollection-Member
System.Web.Services.Protocols-Namespace
Remove
IList
SoapHeader-Klasse