MimePartCollection.IndexOf(MimePart) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Recherche le MimePart spécifié et retourne l'index de base zéro de la première occurrence dans la collection.
public:
int IndexOf(System::Web::Services::Description::MimePart ^ mimePart);
public int IndexOf (System.Web.Services.Description.MimePart mimePart);
member this.IndexOf : System.Web.Services.Description.MimePart -> int
Public Function IndexOf (mimePart As MimePart) As Integer
Paramètres
- mimePart
- MimePart
MimePart pour lequel MimePartCollection doit être recherché.
Retours
Entier signé 32 bits.
Exemples
L’exemple suivant illustre une utilisation classique de la IndexOf
méthode.
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 successfully inserted at position: {0}", myMimePartCollection->IndexOf( myMimePart1 ) );
}
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 successfully inserted at position: "
+myMimePartCollection.IndexOf(myMimePart1));
}
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 successfully inserted at position: " + _
myMimePartCollection.IndexOf(myMimePart1).ToString())
End If
S’applique à
Collaborer avec nous sur GitHub
La source de ce contenu se trouve sur GitHub, où vous pouvez également créer et examiner les problèmes et les demandes de tirage. Pour plus d’informations, consultez notre guide du contributeur.