To Meters from unit - CSharp System

CSharp examples for System:Math Geometry

Description

To Meters from unit

Demo Code


using System.Windows;
using Microsoft.SqlServer.Types;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from w  w w. j a v  a  2s  . co m

public class Main{
        public static double ToMeters(double distance, string unit)
        {
            if (unit.Equals("Meter"))
                return distance;
            else if (unit.Equals("Kilometer"))
                return distance * 1000;
            else if (unit.Equals("Feet"))
                return distance * 0.3048;
            else
                return distance * 1609.344;

        }
}

Related Tutorials