Message.RemoveField

Method

Visual Basic

Overloads Public Sub RemoveField(
    ByVal messageField As MessageField)
Overloads Public Sub RemoveField(
    ByVal fieldName As String)
Overloads Public Sub RemoveField(
    ByVal fieldName As String,
    ByVal fieldId As UInt16)

C#

public void RemoveField(
    MessageField messageField );
public void RemoveField(
    string fieldName );
public void RemoveField(
    string fieldName,
    ushort fieldId );

Purpose

Remove a field from a message.

Parameter

Description

messageField

The parameter is a message field object, which specifies either the field name, the field identifier, or both; see MessageField.

fieldName

Remove the field with this name.

fieldId

Remove the field with this identifier. MessageField.NoSpecificId (zero) is a special value that signifies no identifier.

Field Search Algorithm

This method uses this algorithm to find and remove a field within a message, as specified by a field identifier and a field name.

Procedure 

1. If the program supplied MessageField.NoSpecificId (zero) as the identifier, or omitted any identifier, then begin at step 3.

If the program supplied a non-zero field identifier, then search for the field with that identifier. If the search succeeds, remove the field and return.

On the search does not find a field, continue to step 2.

2. If the identifier search (in step 1) fails, and the program supplied a non-null field name, then search for a field with that name.

On the search does not find a field, or if the program supplied null as the field name, throw an exception with the status code NotFound.

If the name search succeeds, but the actual identifier in the field is non-zero (so it does not match the identifier supplied) then throw an exception with the status code IDConflict.

If the search succeeds, remove the field and return.

3. When the program supplied MessageField.NoSpecificId (zero) as the identifier, or omitted any identifier, then begin here.

Search for a field with the specified name—even if that name is null.

If the search succeeds, remove the field and return.

If the search does not find a field, throw an exception with the status code NotFound.

If a message contains several fields with the same name, searching by name removes the first instance of the field with that name.