Measurements
Type-Safe Measurements Calculations
In One Line
Measure with confidence: Type-safe units, zero confusion!
Overview
Metric is a lightweight, type-safe library for handling length, area and weight measurements in different units. It prevents common unit conversion errors and provides a fluent API for calculations.
Package Info
display name
AceLand Measurements
package name
latest version
1.0.1
namespace
git repository
dependencies
Quick Start
// Create lengths using extension methods
Length height = 1.8.Meters();
Length width = 42.Inches();
Weight playerWeight = 180.Pounds();
Weight itemWeight = 500.Grams();
// Easy unit conversion - no calculations needed
double heightInFeet = height.Feet; // 5.905512 ft
double widthInMeters = width.Meters; // 1.0668 m
double kg = playerWeight.Kilograms; // ~81.64 kg
double oz = itemWeight.Ounces; // ~17.63 oz
// Create area from length multiplication
Area room = width * height;
double areaInSquareMeters = room.SquareMeters; // 1.92024 m²
double areaInSquareFeet = room.SquareFeet; // 20.67 ft²
// Other Calculations
Length totalSideLenght = (height + width) * 2;
Weight totalWeight = playerWeight + itemWeight;
Weight diffWeight = playerWeight - itemWeight;Features
Type-safe measurements
Automatic unit conversion
Support for SI units and Imperial/US units
Clean, fluent API
Zero-allocation operations
Common Usage
Length Units
Area Units
Real-World Examples
Room Dimensions
Land Measurements
Best Practices
Use the most appropriate unit for your input data
Let the library handle all conversions
Use type inference with the fluent API
Take advantage of the built-in ToString() methods for debugging
Notes
All calculations maintain double precision
Internal storage uses meters and square meters
Conversions use standard SI definitions
Zero allocation for basic operations
Last updated