Formats the distance. - CSharp System

CSharp examples for System:Math Number

Description

Formats the distance.

Demo Code


using System;/*from   w ww  .  j av a2s .  c om*/

public class Main{
        /// <summary>
      /// Formats the distance.
      /// </summary>
      /// <returns>The distance in meters</returns>
      /// <param name="distance">Distance.</param>
      public static string FormatDistance(double distance)
      {
         var km = distance / 1000;
         var roundedKm = Math.Round (km, 1);
         return string.Format ("{0}km", roundedKm);
      }
}

Related Tutorials