Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Fügt der MimePartCollection am angegebenen Index den angegebenen MimePart hinzu.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
Syntax
'Declaration
Public Sub Insert ( _
index As Integer, _
mimePart As MimePart _
)
'Usage
Dim instance As MimePartCollection
Dim index As Integer
Dim mimePart As MimePart
instance.Insert(index, mimePart)
public void Insert (
int index,
MimePart mimePart
)
public:
void Insert (
int index,
MimePart^ mimePart
)
public void Insert (
int index,
MimePart mimePart
)
public function Insert (
index : int,
mimePart : MimePart
)
Parameter
- index
Der nullbasierte Index, an dem der mimePart-Parameter eingefügt werden soll.
- mimePart
Der der Auflistung hinzuzufügende MimePart.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der index-Parameter ist kleiner als 0. – oder – Der index-Parameter ist größer als Count. |
Hinweise
Wenn die Anzahl der Elemente in der Auflistung bereits der Kapazität der Auflistung entspricht, wird diese verdoppelt, indem das interne Array vor dem Einfügen des neuen Elements automatisch neu reserviert wird.
Wenn der index-Parameter gleich Count ist, wird der mimePart-Parameter am Ende der MimePartCollection hinzugefügt.
Die Elemente nach der Einfügemarke werden nach unten verschoben, um das neue Element aufnehmen zu können.
Beispiel
Das folgende Beispiel veranschaulicht eine typische Verwendung der Insert-Methode.
Dim myMimeMultipartRelatedBinding As MimeMultipartRelatedBinding = Nothing
Dim myIEnumerator As IEnumerator = myOutputBinding.Extensions.GetEnumerator()
While myIEnumerator.MoveNext()
myMimeMultipartRelatedBinding = CType(myIEnumerator.Current, MimeMultipartRelatedBinding)
End While
' Create an instance of 'MimePartCollection'.
Dim myMimePartCollection As New MimePartCollection()
myMimePartCollection = myMimeMultipartRelatedBinding.Parts
Console.WriteLine("Total number of mimepart elements in the collection initially" + _
" is: " + myMimePartCollection.Count.ToString())
' Get the type of first 'Item' in collection.
Console.WriteLine("The first object in collection is of type: " + _
myMimePartCollection.Item(0).ToString())
Dim myMimePart1 As New MimePart()
' Create an instance of 'MimeXmlBinding'.
Dim myMimeXmlBinding1 As New MimeXmlBinding()
myMimeXmlBinding1.Part = "body"
myMimePart1.Extensions.Add(myMimeXmlBinding1)
' a mimepart at first position.
myMimePartCollection.Insert(0, myMimePart1)
Console.WriteLine("Inserting a mimepart object...")
' Check whether 'Insert' was successful or not.
If myMimePartCollection.Contains(myMimePart1) Then
' Display the index of inserted 'MimePart'.
Console.WriteLine("'MimePart' is succesfully inserted at position: " + _
myMimePartCollection.IndexOf(myMimePart1).ToString())
End If
MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator();
while(myIEnumerator.MoveNext())
{
myMimeMultipartRelatedBinding=(MimeMultipartRelatedBinding)myIEnumerator.Current;
}
// Create an instance of 'MimePartCollection'.
MimePartCollection myMimePartCollection = new MimePartCollection();
myMimePartCollection= myMimeMultipartRelatedBinding.Parts;
Console.WriteLine("Total number of mimepart elements in the collection initially"+
" is: " +myMimePartCollection.Count);
// Get the type of first 'Item' in collection.
Console.WriteLine("The first object in collection is of type: "
+myMimePartCollection[0].ToString());
MimePart myMimePart1=new MimePart();
// Create an instance of 'MimeXmlBinding'.
MimeXmlBinding myMimeXmlBinding1 = new MimeXmlBinding();
myMimeXmlBinding1.Part = "body";
myMimePart1.Extensions.Add(myMimeXmlBinding1);
// a mimepart at first position.
myMimePartCollection.Insert(0,myMimePart1);
Console.WriteLine("Inserting a mimepart object...");
// Check whether 'Insert' was successful or not.
if(myMimePartCollection.Contains(myMimePart1))
{
// Display the index of inserted 'MimePart'.
Console.WriteLine("'MimePart' is succesfully inserted at position: "
+myMimePartCollection.IndexOf(myMimePart1));
}
MimeMultipartRelatedBinding^ myMimeMultipartRelatedBinding = nullptr;
IEnumerator^ myIEnumerator = myOutputBinding->Extensions->GetEnumerator();
while ( myIEnumerator->MoveNext() )
myMimeMultipartRelatedBinding = (MimeMultipartRelatedBinding^)myIEnumerator->Current;
// Create an instance of 'MimePartCollection'.
MimePartCollection^ myMimePartCollection = gcnew MimePartCollection;
myMimePartCollection = myMimeMultipartRelatedBinding->Parts;
Console::WriteLine( "Total number of mimepart elements in the collection initially is: {0}", myMimePartCollection->Count );
// Get the type of first 'Item' in collection.
Console::WriteLine( "The first object in collection is of type: {0}", myMimePartCollection[ 0 ] );
MimePart^ myMimePart1 = gcnew MimePart;
// Create an instance of 'MimeXmlBinding'.
MimeXmlBinding^ myMimeXmlBinding1 = gcnew MimeXmlBinding;
myMimeXmlBinding1->Part = "body";
myMimePart1->Extensions->Add( myMimeXmlBinding1 );
// a mimepart at first position.
myMimePartCollection->Insert( 0, myMimePart1 );
Console::WriteLine( "Inserting a mimepart object..." );
// Check whether 'Insert' was successful or not.
if ( myMimePartCollection->Contains( myMimePart1 ) )
{
// Display the index of inserted 'MimePart'.
Console::WriteLine( "'MimePart' is succesfully inserted at position: {0}", myMimePartCollection->IndexOf( myMimePart1 ) );
}
MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
IEnumerator myIEnumerator = myOutputBinding.get_Extensions().
GetEnumerator();
while (myIEnumerator.MoveNext()) {
myMimeMultipartRelatedBinding =
(MimeMultipartRelatedBinding)myIEnumerator.get_Current();
}
// Create an instance of 'MimePartCollection'.
MimePartCollection myMimePartCollection = new MimePartCollection();
myMimePartCollection = myMimeMultipartRelatedBinding.get_Parts();
Console.WriteLine("Total number of mimepart elements in the collection "
+ "initially is: " + myMimePartCollection.get_Count());
// Get the type of first 'Item' in collection.
Console.WriteLine("The first object in collection is of type: "
+ myMimePartCollection.get_Item(0).ToString());
MimePart myMimePart1 = new MimePart();
// Create an instance of 'MimeXmlBinding'.
MimeXmlBinding myMimeXmlBinding1 = new MimeXmlBinding();
myMimeXmlBinding1.set_Part("body");
myMimePart1.get_Extensions().Add(myMimeXmlBinding1);
// a mimepart at first position.
myMimePartCollection.Insert(0, myMimePart1);
Console.WriteLine("Inserting a mimepart object...");
// Check whether 'Insert' was successful or not.
if (myMimePartCollection.Contains(myMimePart1)) {
// Display the index of inserted 'MimePart'.
Console.WriteLine("'MimePart' is succesfully inserted at position: "
+ myMimePartCollection.IndexOf(myMimePart1));
}
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
MimePartCollection-Klasse
MimePartCollection-Member
System.Web.Services.Description-Namespace