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


Get NAClass Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Get NAClass Snippet

Get the specified NAClass from a network analysis layer.

[C#]
///<summary>Get the specified NAClass from a network analysis layer.</summary>
/// 
///<param name="nalayer">An INALayer3 interface.</param>
///<param name="naClassName">A System.String that is the NAClass to retrieve. Ex: "Stops"</param>
/// 
///<returns>An INAClass interface.</returns>
/// 
///<remarks></remarks>
public ESRI.ArcGIS.NetworkAnalyst.INAClass GetNAClass(ESRI.ArcGIS.NetworkAnalyst.INALayer3 nalayer, System.String naClassName)
{

  ESRI.ArcGIS.NetworkAnalyst.INAContext naContext=nalayer.Context;
  ESRI.ArcGIS.NetworkAnalyst.INamedSet namedSet=naContext.NAClasses;
  ESRI.ArcGIS.NetworkAnalyst.INAClass naClass=namedSet.get_ItemByName(naClassName) as ESRI.ArcGIS.NetworkAnalyst.INAClass; // Dynamic Cast

  return naClass;

}
[Visual Basic .NET]
'''<summary>Get the specified NAClass from a network analysis layer.</summary>
''' 
'''<param name="nalayer">An INALayer3 interface.</param>
'''<param name="naClassName">A System.String that is the NAClass to retrieve. Ex: "Stops"</param>
''' 
'''<returns>An INAClass interface.</returns>
''' 
'''<remarks></remarks>
Public Function GetNAClass(ByVal nalayer As ESRI.ArcGIS.NetworkAnalyst.INALayer3, ByVal naClassName As System.String) As ESRI.ArcGIS.NetworkAnalyst.INAClass

  Dim naContext As ESRI.ArcGIS.NetworkAnalyst.INAContext=nalayer.Context
  Dim namedSet As ESRI.ArcGIS.NetworkAnalyst.INamedSet=naContext.NAClasses
  Dim naClass As ESRI.ArcGIS.NetworkAnalyst.INAClass=TryCast(namedSet.ItemByName(naClassName), ESRI.ArcGIS.NetworkAnalyst.INAClass) ' Dynamic Cast

  Return naClass

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.NetworkAnalyst