Table of Contents

MetricPrefixTable Class

Definition

Namespace
Codebelt.Unitify
Assemblies
Codebelt.Unitify.dll
Source
src/Codebelt.Unitify/MetricPrefixTable.cs

Represents a table of metric prefixes for units of measure, optimized for metric measurement standards.

Examples

Browse all decimal prefix representations of a SI unit. This example creates a MetricPrefixTable from a watt quantity, then displays both the full table showing all decimal-scaled (power-of-10) representations and an aggregate summary indicating which SI prefix scales are available for that unit value:

using System;
using Codebelt.Unitify;

namespace Unitify.Samples;

public class MetricPrefixTableExample
{
    public static void Main()
    {
        // Create a unit: 11,745 watts (approximately 11.745 kW)
        var wattUnit = UnitFactory.CreateWatt(11745);
        
        // Create a metric prefix table to see all decimal scales
        var table = new MetricPrefixTable(wattUnit);
        
        // Display all representations from quecto to yotta
        Console.WriteLine("Metric prefix representations:");
        Console.WriteLine(table.ToString());
        
        // Show aggregate summary
        Console.WriteLine("\nAggregate:");
        Console.WriteLine(table.ToAggregateString());
    }
}
public class MetricPrefixTable : PrefixTable, IEquatable<IUnit>, IEnumerable<IPrefixUnit>, IEnumerable
Inheritance
MetricPrefixTable
Implements
Inherited Members
Extension Methods

Constructors

Name Description
MetricPrefixTable(IUnit)

Initializes a new instance of the MetricPrefixTable class.

Methods

Name Description
GetEnumerator()

Returns an enumerator that iterates through the multiples and submultiples of the base unit.

ToAggregateString(bool, bool, bool)

Returns an aggregated string of all multiple and sub-multiple prefix of this instance.

ToString()

Returns a string that represents the first prefix greater or equal to one of this instance.