This is the project page for the Nuget package Units.Conversions which, once installed, allows you to convert the following units:
Length | Temperature | Speed | Fuel Economy | Frequency |
---|---|---|---|---|
Kilometers | Celsius | Miles per hour | Miles per gallon | Hertz |
Meters | Farenheit | Feet per second | Imperial miles per gallon | Kilohertz |
Centimerters | Kelvin | Meters per second | Kilometers per liter | Megahertz |
Millimeters | Kilometers per hour | Liters per 100km | Gigahertz | |
Micrometers | Knots | |||
Nanometers | ||||
Miles | ||||
Yards | ||||
Feet | ||||
Inches | ||||
Nautical Miles |
Area | Plane angles |
---|---|
Square Kilometers | Degrees |
Square Meters | Gradians |
Square Mile | Milliradians |
Square Yard | Minutes of arc |
Square Foot | Radians |
Square Inch | Seconds of arc |
Hectare | |
Acre |
To use this package, add the relevant using
statements:
using Conversions
- which gives access to theLength
propertyusing Conversions.UnitsOfTemperature
- which gives access to theTemperature
propertyusing Conversions.UnitsOfSpeed
- which gives access to theSpeed
propertyusing Conversions.UnitsOfFuelEconomy
- which gives access to theFuelEconomy
propertyusing Conversions.UnitsOfFrequency
- which gives access to theFrequency
propertyusing Conversions.UnitsOfArea
- which gives access to theArea
propertyusing Conversions.UnitsOfPlaneAngle
- which gives access to thePlane Angle
property
For example:
using Conversions
using Conversions.UnitsOfTemperature;
using Conversions.UnitsOfSpeed;
using Conversions.UnitsOfFuelEconomy;
using Conversions.UnitsOfFrequency;
using Conversions.UnitsOfArea;
using Conversions.UnitsOfPlaneAngle;
namespace SampleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Convert 1 Foot to Centimeters");
var cm = Length.FootToCentimeter(1);
Console.WriteLine(cm);
Console.WriteLine("Convert 10 degrees C to Farenheit");
var F = Temperature.CelciusToFarenheit(10);
Console.WriteLine(F);
Console.WriteLine("Convert 60 mph to Kph");
var kph = Speed.MilesPerHourToKilometersPerHour(60);
Console.WriteLine(kph);
Console.WriteLine("Convert 40 mpg to Kpl");
var kpl = FuelEconomy.MilesPerGallonToKilometersPerLitre(40);
Console.WriteLine(kpl);
Console.WriteLine("Convert 1500 hertz to Kilohertz");
var khtz = Frequency.HertzToKilohertz(1500);
Console.WriteLine(khtz);
Console.WriteLine("Convert 20 square kilometers to Acres");
var acres = Area.SquareKilometerToAcre(20);
Console.WriteLine(acres);
Console.WriteLine("Convert 45degrees to Radians");
var rads = PlaneAngle.DegreeToRadian(45);
Console.WriteLine(rads);
}
}
}