Table of Contents

Class MetricPrefixTable

Namespace
Codebelt.Unitify
Assembly
Codebelt.Unitify.dll

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

MetricPrefixTable(IUnit)

Initializes a new instance of the MetricPrefixTable class.

public MetricPrefixTable(IUnit unit)

Parameters

unit IUnit

The instance of an object that implements the IUnit interface.

Methods

GetEnumerator()

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

public override IEnumerator<IPrefixUnit> GetEnumerator()

Returns

IEnumerator<IPrefixUnit>

An enumerator that can be used to iterate through 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.

public string ToAggregateString(bool includeMultiples = true, bool includeSubmultiples = true, bool includeUnit = true)

Parameters

includeMultiples bool

if set to true all multiple prefix is included in the aggregate.

includeSubmultiples bool

if set to true all submultiple prefix is included in the aggregate.

includeUnit bool

if set to true the base unit is included in the aggregate.

Returns

string

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.

public override string ToString()

Returns

string

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