Export (0) Print
Expand All

MimeTextMatchCollection.Insert Method

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

Namespace:  System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

public void Insert(
	int index,
	MimeTextMatch match
)

Parameters

index
Type: System.Int32

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

match
Type: System.Web.Services.Description.MimeTextMatch

The MimeTextMatch to add to the collection.

ExceptionCondition
IndexOutOfRangeException

The index parameter is less than zero.

- or -

The index parameter is greater than Count.

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.

The following example demonstrates the use of the Insert method.

// 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 ] );
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft