This document is archived and information here might be outdated.  Recommended version.


INAClassDefinition.FieldType Property (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > NetworkAnalyst > ESRI.ArcGIS.NetworkAnalyst > Interfaces > IN > INAClassDefinition Interface > INAClassDefinition.FieldType Property
ArcGIS Developer Help

INAClassDefinition.FieldType Property

The field type for a network analyst class field.

[Visual Basic .NET]
Public Function get_FieldType ( _
    ByVal FieldName As String _
) As Integer
[C#]
public int get_FieldType (
    string FieldName
);
[C++]
HRESULT get_FieldType(
  BSTR FieldName,
  System.Int32* naFieldType
);
[C++]
Parameters
FieldName [in]

FieldName is a parameter of type BSTR naFieldType [out, retval]
naFieldType is a parameter of type long*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.

Remarks

FieldType specifies how the field is to be used by returning a combination of bits defined in esriNAFieldType.

The valid values for this property are 0 - 63.  Each bit represents one of the enumeration settings in esriNAFieldType.

 

Thus, if a field is used for input to the solver, but is not editable (e.g. the Status field) the FieldType would be esriNAFieldTypeInput + esriNAFieldTypeNotEditable which would equal 9.

[C#]

This C# example shows how you can programatically retrieve the FieldType and perform bitwise calculations to determine the type.

public void ShowFieldType(INAClass naClass)
{
    // Get the class definition 
    INAClassDefinition naClassDefinition = naClass.ClassDefinition;

    // Loop though the FieldType for each Field
    string fieldName;
    int fieldType;
    for (int i = 0; i < naClassDefinition.Fields.FieldCount; i++)
    {
        fieldName = naClassDefinition.Fields.get_Field(i).Name;
        fieldType = naClassDefinition.get_FieldType(fieldName);
        // Output the fieldName, the fieldType value, and the string of what the fieldType means.
        Console.WriteLine("{0} - {1} - {2}", fieldName, fieldType, ConvertFieldTypeToString(fieldType));
    }
}
private string ConvertFieldTypeToString(int fieldTypeInt)
{
    string fieldTypes = string.Empty;
    esriNAFieldType fieldType = (esriNAFieldType)fieldTypeInt;
    if ((fieldType & esriNAFieldType.esriNAFieldTypeInput) == esriNAFieldType.esriNAFieldTypeInput)
        fieldTypes += ",esriNAFieldTypeInput"; // It is an Input Field
    if ((fieldType & esriNAFieldType.esriNAFieldTypeOutput) == esriNAFieldType.esriNAFieldTypeOutput)
        fieldTypes += ",esriNAFieldTypeOutput"; // It is an Output Field
    if ((fieldType & esriNAFieldType.esriNAFieldTypeNotVisible) == esriNAFieldType.esriNAFieldTypeNotVisible)
        fieldTypes += ",esriNAFieldTypeNotVisible"; // The field is Not Visible (and not shown in the NAWindow)
    if ((fieldType & esriNAFieldType.esriNAFieldTypeNotEditable) == esriNAFieldType.esriNAFieldTypeNotEditable)
        fieldTypes += ",esriNAFieldTypeNotEditable"; // The field is Not Editable (and can not be edited using the Network Location Properties Window)
    if ((fieldType & esriNAFieldType.esriNAFieldTypeSequence) == esriNAFieldType.esriNAFieldTypeSequence)
        fieldTypes += ",esriNAFieldTypeSequence"; // The field type is Sequence
    if ((fieldType & esriNAFieldType.esriNAFieldTypeGroup) == esriNAFieldType.esriNAFieldTypeGroup)
        fieldTypes += ",esriNAFieldTypeGroup"; // The field type is Group
    if (fieldTypes != string.Empty)
        fieldTypes = fieldTypes.Substring(1);
    return fieldTypes;
}
[Visual Basic .NET]

This VB.NET example shows how you can programatically retrieve the FieldType and perform bitwise calculations to determine the type.

Public  Sub ShowFieldType(ByVal naClass As INAClass)
    ' Get the class definition  
    Dim naClassDefinition As INAClassDefinition =  naClass.ClassDefinition 
 
    ' Loop though the FieldType for each Field
    Dim fieldName As String
    Dim fieldType As Integer
    Dim i As Integer
    For  i = 0 To  naClassDefinition.Fields.FieldCount- 1  Step  i + 1
        fieldName = naClassDefinition.Fields.Field(i).Name
        fieldType = naClassDefinition.FieldType(fieldName)
 
        ' Output the fieldName, the fieldType value, and the string of what the fieldType means.
        Console.WriteLine("{0} - {1} - {2}", fieldName, fieldType, ConvertFieldTypeToString(fieldType))
    Next
End Sub
 
Private Function ConvertFieldTypeToString(ByVal fieldTypeInt As Integer) As String
    Dim fieldTypes As String =  String.Empty 
 
    Dim fieldType As esriNAFieldType = CType(fieldTypeInt, esriNAFieldType)
    If (fieldType & esriNAFieldType.esriNAFieldTypeInput) = esriNAFieldType.esriNAFieldTypeInput Then
        fieldTypes += ",esriNAFieldTypeInput" ' It is an Input Field
    End If
 
    If (fieldType & esriNAFieldType.esriNAFieldTypeOutput) = esriNAFieldType.esriNAFieldTypeOutput Then
        fieldTypes += ",esriNAFieldTypeOutput" ' It is an Output Field
    End If
 
    If (fieldType & esriNAFieldType.esriNAFieldTypeNotVisible) = esriNAFieldType.esriNAFieldTypeNotVisible Then
        fieldTypes += ",esriNAFieldTypeNotVisible" ' The field is Not Visible (and not shown in the NAWindow)
    End If
 
    If (fieldType & esriNAFieldType.esriNAFieldTypeNotEditable) = esriNAFieldType.esriNAFieldTypeNotEditable Then
        fieldTypes += ",esriNAFieldTypeNotEditable" ' The field is Not Editable (and can not be edited using the Network Location Properties Window)
    End If
    
    If (fieldType & esriNAFieldType.esriNAFieldTypeSequence) = esriNAFieldType.esriNAFieldTypeSequence Then
        fieldTypes += ",esriNAFieldTypeSequence" ' The field type is Sequence
    End If

    If (fieldType & esriNAFieldType.esriNAFieldTypeGroup) = esriNAFieldType.esriNAFieldTypeGroup Then
        fieldTypes += ",esriNAFieldTypeGroup" ' The field type is Group
    End If

    If fieldTypes <> String.Empty Then
        fieldTypes = fieldTypes.Substring(1)
    End If
 
    Return fieldTypes
End Function

See Also

INAClassDefinition Interface

.NET Samples

ArcGIS Network Analyst extension Engine application