This documentation is archived and is not being maintained.

MimePartCollection.Item Property

Gets or sets the value of a MimePart at the specified zero-based index.

[C#] In C#, this property is the indexer for the MimePartCollection class.

[Visual Basic]
Public Default Property Item( _
   ByVal index As Integer _
) As MimePart
[C#]
public MimePart this[
 int index
] {get; set;}
[C++]
public: __property MimePart* get_Item(
 int index
);
public: __property void set_Item(
 int index,
   MimePart*
);
[JScript]
returnValue = MimePartCollectionObject.Item(index);
MimePartCollectionObject.Item(index) = returnValue;
-or-
returnValue = MimePartCollectionObject(index);
MimePartCollectionObject(index) = returnValue;

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.

Arguments [JScript]

index
The zero-based index of the MimePart whose value is modified or returned.

Parameters [Visual Basic, C#, C++]

index
The zero-based index of the MimePart whose value is modified or returned.

Property Value

A MimePart.

Example

[Visual Basic, C#, C++] The following example demonstrates the use of a zero-based index to retrieve a member of the MimePartCollection.

[Visual Basic] 
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

[C#] 
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));         
}

[C++] 
MimeMultipartRelatedBinding* myMimeMultipartRelatedBinding = 0;
IEnumerator* myIEnumerator = myOutputBinding->Extensions->GetEnumerator();
while(myIEnumerator->MoveNext())
   myMimeMultipartRelatedBinding = 
   dynamic_cast<MimeMultipartRelatedBinding*>(myIEnumerator->Current);
// Create an instance of 'MimePartCollection'.
MimePartCollection* myMimePartCollection = new MimePartCollection();
myMimePartCollection= myMimeMultipartRelatedBinding->Parts;
Console::WriteLine(S"Total number of mimepart elements in the collection initially  is: {0}", 
   __box(myMimePartCollection->Count));
// Get the type of first 'Item' in collection.
Console::WriteLine(S"The first object in collection is of type: {0}", 
   myMimePartCollection->Item[0]);
MimePart* myMimePart1 = new MimePart();
// Create an instance of 'MimeXmlBinding'.
MimeXmlBinding* myMimeXmlBinding1 = new MimeXmlBinding();
myMimeXmlBinding1->Part = S"body";
myMimePart1->Extensions->Add(myMimeXmlBinding1);
//  a mimepart at first position.
myMimePartCollection->Insert(0, myMimePart1);
Console::WriteLine(S"Inserting a mimepart object...");
// Check whether 'Insert' was successful or not.
if (myMimePartCollection->Contains(myMimePart1))
{
   // Display the index of inserted 'MimePart'.
   Console::WriteLine(S"'MimePart' is succesfully inserted at position: {0}", 
      __box(myMimePartCollection->IndexOf(myMimePart1)));
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

MimePartCollection Class | MimePartCollection Members | System.Web.Services.Description Namespace

Show: