This documentation is archived and is not being maintained.

MimeTextMatchCollection.Insert Method

Adds the specified MimeTextMatch to the MimeTextMatchCollection at the specified index.

[Visual Basic]
Public Sub Insert( _
   ByVal index As Integer, _
   ByVal match As MimeTextMatch _
)
[C#]
public void Insert(
 int index,
 MimeTextMatch match
);
[C++]
public: void Insert(
 int index,
 MimeTextMatch* match
);
[JScript]
public function Insert(
   index : int,
 match : MimeTextMatch
);

Parameters

index
The zero-based index at which to insert the match parameter.
match
The MimeTextMatch to add to the collection.

Exceptions

Exception Type Condition
IndexOutOfRangeException The index parameter is less than zero.

- or -

The index parameter is greater than Count.

Remarks

If the number of items in the collection already equals the collection's capacity, the capacity is doubled by automatically reallocating the internal array before the new element is inserted.

If the index parameter is equal to Count, the match parameter is added to the end of the MimeTextMatchCollection.

The elements after the insertion point move down to accommodate the new element.

Example

[Visual Basic, C#, C++] The following example demonstrates the use of the Insert method.

[Visual Basic] 
' Get an instance of 'MimeTextMatchCollection'.
Dim myMimeTextMatchCollection1 As New MimeTextMatchCollection()
Dim myMimeTextMatch1(4) As MimeTextMatch
myMimeTextMatchCollection1 = myMimeTextBinding1.Matches
For myInt = 0 To 3
   myMimeTextMatch1(myInt) = New MimeTextMatch()
   myMimeTextMatch1(myInt).Name = "Title" + Convert.ToString(myInt)
   If myInt <> 0 Then
      myMimeTextMatch1(myInt).RepeatsString = "7"
   End If
   myMimeTextMatchCollection1.Add(myMimeTextMatch1(myInt))
Next myInt
myMimeTextMatch1(4) = New MimeTextMatch()
' Remove 'MimeTextMatch' instance from collection.
myMimeTextMatchCollection1.Remove(myMimeTextMatch1(1))
' Using MimeTextMatchCollection.Item indexer to comapre. 
If myMimeTextMatch1(2) Is myMimeTextMatchCollection1(1) Then
   ' Check whether 'MimeTextMatch' instance exists. 
   myInt = myMimeTextMatchCollection1.IndexOf(myMimeTextMatch1(2))
   ' Insert 'MimeTextMatch' instance at a desired position.
   myMimeTextMatchCollection1.Insert(1, myMimeTextMatch1(myInt))
   myMimeTextMatchCollection1(1).RepeatsString = "5"
   myMimeTextMatchCollection1.Insert(4, myMimeTextMatch1(myInt))
End If

[C#] 
// Get an instance of 'MimeTextMatchCollection'.
MimeTextMatchCollection myMimeTextMatchCollection1 = new MimeTextMatchCollection();
MimeTextMatch[] myMimeTextMatch1 = new MimeTextMatch[5];
myMimeTextMatchCollection1 = myMimeTextBinding1.Matches;
for( myInt = 0 ; myInt < 4 ; myInt++ )
{
   myMimeTextMatch1[ myInt ]  = new MimeTextMatch();
   myMimeTextMatch1[ myInt ].Name = "Title" + Convert.ToString( myInt );
   if( myInt != 0 )
   {
      myMimeTextMatch1[ myInt ].RepeatsString = "7";
   }
   myMimeTextMatchCollection1.Add( myMimeTextMatch1[ myInt ] );
}
myMimeTextMatch1[4] = new MimeTextMatch();
// Remove 'MimeTextMatch' instance from collection.
myMimeTextMatchCollection1.Remove( myMimeTextMatch1[ 1 ] );
// Using MimeTextMatchCollection.Item indexer to comapre. 
if( myMimeTextMatch1[ 2 ] == myMimeTextMatchCollection1[ 1 ] )
{
   // Check whether 'MimeTextMatch' instance exists. 
   myInt = myMimeTextMatchCollection1.IndexOf( myMimeTextMatch1[ 2 ] );
   // Insert 'MimeTextMatch' instance at a desired position.
   myMimeTextMatchCollection1.Insert( 1, myMimeTextMatch1[ myInt ] );
   myMimeTextMatchCollection1[ 1 ].RepeatsString = "5";
   myMimeTextMatchCollection1.Insert( 4, myMimeTextMatch1[ myInt ] );
}

[C++] 
// Get an instance of 'MimeTextMatchCollection'.
MimeTextMatchCollection* myMimeTextMatchCollection1 = new MimeTextMatchCollection();
MimeTextMatch* myMimeTextMatch1[] = new MimeTextMatch*[5];
myMimeTextMatchCollection1 = myMimeTextBinding1->Matches;
for( myInt = 0 ; myInt < 4 ; myInt++ )
{
   myMimeTextMatch1[ myInt ]  = new MimeTextMatch();
   myMimeTextMatch1[ myInt ]->Name = String::Format( S"Title{0}", Convert::ToString(myInt) );
   if( myInt != 0 )
   {
      myMimeTextMatch1[ myInt ]->RepeatsString = S"7";
   }
   myMimeTextMatchCollection1->Add( myMimeTextMatch1[ myInt ] );
}
myMimeTextMatch1[4] = new MimeTextMatch();
// Remove 'MimeTextMatch' instance from collection.
myMimeTextMatchCollection1->Remove( myMimeTextMatch1[ 1 ] );
// Using MimeTextMatchCollection.Item indexer to comapre. 
if( myMimeTextMatch1->Item[ 2 ] == myMimeTextMatchCollection1->Item[ 1 ] )
{
   // Check whether 'MimeTextMatch' instance exists. 
   myInt = myMimeTextMatchCollection1->IndexOf( myMimeTextMatch1[ 2 ] );
   // Insert 'MimeTextMatch' instance at a desired position.
   myMimeTextMatchCollection1->Insert( 1, myMimeTextMatch1[ myInt ] );
   myMimeTextMatchCollection1->Item[ 1 ]->RepeatsString = S"5";
   myMimeTextMatchCollection1->Insert( 4, myMimeTextMatch1[ myInt ] );
}

[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

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

Show: