Пример #1
0
 /// <summary>
 /// Insert a field at the desired index.  If the field already exists in the mesg it is first removed.
 /// </summary>
 /// <param name="index">Index to insert the field, if index is out of range, the field is added to the end of the list</param>
 /// <param name="field">Caller allocated field</param>
 public void InsertField(int index, Field field)
 {
     // if message already contains this field, remove it
     for (int i = 0; i < FieldsList.Count; i++)
     {
         if (FieldsList[i].Num == field.Num)
         {
             FieldsList.RemoveAt(i);
         }
     }
     // if the index is out of range, add to the end
     if (index < 0 || index > FieldsList.Count)
     {
         FieldsList.Add(field);
     }
     // insert the new field at desired index
     else
     {
         FieldsList.Insert(index, field);
     }
 }