Returns the name of the Unit used internally.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
Field Value
A String containing the name of the Unit.Remarks
The Name property returns a string indicating the name used internally for the specified Unit and is used in .prj files. The Name property is not ideal for displaying units to the user as it may contain underscores or other formatting; if you wish to display the units being used in a user interface, you should use either the GetDisplayName(UnitNameOptions) or GetPluralName(UnitNameOptions) method instead.
Examples
The code below uses .NET reflection to find all of the nested type initializers that create new
Unit objects, and then creates an instance of each type of Unit. It then reports on the units by writing to the Debug
window using Name property (and Id property where applicable), listing linear, angular and area units separately.
CopyC#
// Get all the different types of Linear units. System.Reflection.PropertyInfo[] linearProps = typeof(Unit.Linear).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); // Report linear units. System.Diagnostics.Debug.WriteLine("Linear Units are:"); foreach (System.Reflection.PropertyInfo prop in linearProps) { Unit u = prop.GetValue(null, null) as Unit; System.Diagnostics.Debug.WriteLine(u.Name + "(" + u.Id.ToString() + ")"); } // Get all the different types of angular units. System.Reflection.PropertyInfo[] angularProps = typeof(Unit.Angular).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); // Report angular units. System.Diagnostics.Debug.WriteLine("Angular Units are:"); foreach (System.Reflection.PropertyInfo prop in angularProps) { Unit u = prop.GetValue(null, null) as Unit; System.Diagnostics.Debug.WriteLine(u.Name + "(" + u.Id.ToString() + ")"); } // Get all the different types of area units. System.Reflection.PropertyInfo[] areaProps = typeof(Unit.Area).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); // Report area units. System.Diagnostics.Debug.WriteLine("Area Units are:"); foreach (System.Reflection.PropertyInfo prop in areaProps) { Unit u = prop.GetValue(null, null) as Unit; System.Diagnostics.Debug.WriteLine(u.Name); // Area units do not have identifiers. }
CopyVB.NET
' Get all the different types of Linear units. Dim linearProps As System.Reflection.PropertyInfo() = GetType(Unit.Linear).GetProperties(System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Static) ' Report linear units. System.Diagnostics.Debug.WriteLine("Linear Units are:") Dim prop As System.Reflection.PropertyInfo For Each prop In linearProps Dim u As Unit = CType(prop.GetValue(Nothing, Nothing), Unit) System.Diagnostics.Debug.WriteLine(u.Name & "(" & u.Id.ToString() & ")") Next ' Get all the different types of angular units. Dim angularProps As System.Reflection.PropertyInfo() = GetType(Unit.Angular).GetProperties(System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Static) ' Report angular units. System.Diagnostics.Debug.WriteLine("Angular Units are:") For Each prop In angularProps Dim u As Unit = CType(prop.GetValue(Nothing, Nothing), Unit) System.Diagnostics.Debug.WriteLine(u.Name & "(" & u.Id.ToString() & ")") Next ' Get all the different types of area units. Dim areaProps As System.Reflection.PropertyInfo() = GetType(Unit.Area).GetProperties(System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Static) ' Report angular units. System.Diagnostics.Debug.WriteLine("Area Units are:") For Each prop In areaProps Dim u As Unit = CType(prop.GetValue(Nothing, Nothing), Unit) System.Diagnostics.Debug.WriteLine(u.Name) ' Area units do not have Identifiers Next