MimeTextMatchCollection.Insert(Int32, MimeTextMatch) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的 MimeTextMatch 加入至 MimeTextMatchCollection,於指定索引位置。
public:
void Insert(int index, System::Web::Services::Description::MimeTextMatch ^ match);
public void Insert (int index, System.Web.Services.Description.MimeTextMatch match);
member this.Insert : int * System.Web.Services.Description.MimeTextMatch -> unit
Public Sub Insert (index As Integer, match As MimeTextMatch)
參數
- index
- Int32
以零起始的索引,match
參數要在此處插入。
- match
- MimeTextMatch
要加入至集合的 MimeTextMatch。
例外狀況
範例
下列範例示範 Insert
方法的用法。
// Get an instance of 'MimeTextMatchCollection'.
MimeTextMatchCollection^ myMimeTextMatchCollection1 = gcnew MimeTextMatchCollection;
array<MimeTextMatch^>^myMimeTextMatch1 = gcnew array<MimeTextMatch^>(5);
myMimeTextMatchCollection1 = myMimeTextBinding1->Matches;
for ( myInt = 0; myInt < 4; myInt++ )
{
myMimeTextMatch1[ myInt ] = gcnew MimeTextMatch;
myMimeTextMatch1[ myInt ]->Name = String::Format( "Title{0}", Convert::ToString( myInt ) );
if ( myInt != 0 )
{
myMimeTextMatch1[ myInt ]->RepeatsString = "7";
}
myMimeTextMatchCollection1->Add( myMimeTextMatch1[ myInt ] );
}
myMimeTextMatch1[ 4 ] = gcnew 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 ] );
}
// 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 ] );
}
' 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
備註
如果集合中的專案數目已經等於集合的容量,就會在插入新元素之前自動重新配置內部陣列,以加倍容量。
index
如果 參數等於 Count ,則會 match
將 參數新增至 的 MimeTextMatchCollection 結尾。
插入點後的專案會向下移動以容納新的專案。