Table of Contents

DataPrefixTable Class

Definition

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

Represents a table of both binary and metric prefixes for units of measure, optimized for data quantity and transmission measurement standards.

Examples

Browse all binary prefix representations of a data storage unit. This example creates a DataPrefixTable from a byte quantity, then displays both the full table of all binary-scaled representations and an aggregate summary showing which scales are available for that unit value:

using System;
using Codebelt.Unitify;

namespace Unitify.Samples;

public class DataPrefixTableExample
{
    public static void Main()
    {
        // Create a unit representing 1,048,576 bytes (1 MiB)
        var byteUnit = UnitFactory.CreateByte(1048576);
        
        // Create a data prefix table to see all binary scales
        var table = new DataPrefixTable(byteUnit);
        
        // Display all representations
        Console.WriteLine("Data storage representations:");
        Console.WriteLine(table.ToString());
        
        // Show aggregate summary
        Console.WriteLine("\nAggregate:");
        Console.WriteLine(table.ToAggregateString());
    }
}
public class DataPrefixTable : PrefixTable, IEquatable<IUnit>, IEnumerable<IPrefixUnit>, IEnumerable
Inheritance
DataPrefixTable
Implements
Inherited Members
Extension Methods

Constructors

Name Description
DataPrefixTable(IUnit)

Initializes a new instance of the DataPrefixTable class.

Fields

Name Description
DefaultNumberFormat

The default number format used for displaying values related to DataPrefixTable.

Methods

Name Description
CreateBitTableFromBits(double, Action<UnitFormatOptions>)

Creates a new instance of DataPrefixTable initialized with value.

CreateBitTableFromBytes(double, Action<UnitFormatOptions>)

Creates a new instance of DataPrefixTable initialized with value.

CreateByteTableFromBits(double, Action<UnitFormatOptions>)

Creates a new instance of DataPrefixTable initialized with value.

CreateByteTableFromBytes(double, Action<UnitFormatOptions>)

Creates a new instance of DataPrefixTable initialized with value.

GetEnumerator()

Returns an enumerator that iterates through the collection of prefixes.

ToAggregateString(bool, bool, bool)

Returns an aggregated string of all multiple prefixes of this instance.

ToString()

Returns a string that represents the largest multiple prefix of this instance.

ToString(PrefixStyle)

Returns a string that represents the largest multiple prefix of this instance.

See Also