API Reference
EmailFormat
Formatting helpers for common email-friendly value representations (currency, percentages, etc.).
Inheritance
- Object
- EmailFormat
Methods
public static String Bytes(Object value, Int32 decimals = 2, EmailBytesUnitSystem unitSystem = Binary, CultureInfo culture = null) #StringFormats a byte size into a human-readable representation (e.g., "2.47 MB").
Parameters
- bytes System.Int64
- decimals System.Int32 = 2
- unitSystem HtmlForgeX.Email.EmailBytesUnitSystem = Binary
- culture System.Globalization.CultureInfo = null
Bytes(System.Object value, System.Int32 decimals, HtmlForgeX.Email.EmailBytesUnitSystem unitSystem, System.Globalization.CultureInfo culture) #Formats an arbitrary value as a byte size when possible; otherwise falls back to IFormatProvider).
Parameters
- value System.Object
- decimals System.Int32
- unitSystem HtmlForgeX.Email.EmailBytesUnitSystem
- culture System.Globalization.CultureInfo
public static String CompactNumber(Object value, Int32 decimals = 1, EmailCompactNumberCase suffixCase = Lower, CultureInfo culture = null) #StringFormats a number into a compact representation (e.g., "1.2k", "4.7M").
Parameters
- value System.Int64
- decimals System.Int32 = 1
- suffixCase HtmlForgeX.Email.EmailCompactNumberCase = Lower
- culture System.Globalization.CultureInfo = null
CompactNumber(System.Object value, System.Int32 decimals, HtmlForgeX.Email.EmailCompactNumberCase suffixCase, System.Globalization.CultureInfo culture) #Formats an arbitrary value as a compact number when possible; otherwise falls back to IFormatProvider).
Parameters
- value System.Object
- decimals System.Int32
- suffixCase HtmlForgeX.Email.EmailCompactNumberCase
- culture System.Globalization.CultureInfo
public static String Currency(Object value, String currencySymbol = "$", Int32 decimals = 2, CultureInfo culture = null) #StringFormats a numeric value as a currency string using a fixed symbol (e.g., "$12.34").
Parameters
- amount System.Decimal
- currencySymbol System.String = "$"
- decimals System.Int32 = 2
- culture System.Globalization.CultureInfo = null
Currency(System.Object value, System.String currencySymbol, System.Int32 decimals, System.Globalization.CultureInfo culture) #Formats an arbitrary value as currency when possible; otherwise falls back to IFormatProvider).
Parameters
- value System.Object
- currencySymbol System.String
- decimals System.Int32
- culture System.Globalization.CultureInfo
public static String Date(DateTimeOffset value, String format = "MMM d, yyyy", CultureInfo culture = null) #StringFormats a date using a short, email-friendly default (e.g., "Jan 2, 2025").
Parameters
- value System.DateTime
- format System.String = "MMM d, yyyy"
- culture System.Globalization.CultureInfo = null
Date(System.DateTimeOffset value, System.String format, System.Globalization.CultureInfo culture) #Formats a date using a short, email-friendly default (e.g., "Jan 2, 2025").
Parameters
- value System.DateTimeOffset
- format System.String
- culture System.Globalization.CultureInfo
public static String DateTime(DateTimeOffset value, String format = "MMM d, yyyy · h:mm tt", CultureInfo culture = null) #StringFormats a date+time using an email-friendly default (e.g., "Jan 2, 2025 · 1:05 PM").
Parameters
- value System.DateTime
- format System.String = "MMM d, yyyy · h:mm tt"
- culture System.Globalization.CultureInfo = null
DateTime(System.DateTimeOffset value, System.String format, System.Globalization.CultureInfo culture) #Formats a date+time using an email-friendly default (e.g., "Jan 2, 2025 · 1:05 PM").
Parameters
- value System.DateTimeOffset
- format System.String
- culture System.Globalization.CultureInfo
public static String Duration(TimeSpan duration, Int32 maxParts = 2) #StringFormats a duration into a compact representation (e.g., "1h 30m").
Parameters
- duration System.TimeSpan
- maxParts System.Int32 = 2
public static String EnumName<TEnum>(TEnum value, Boolean humanize = true) #StringFormats an enum value for display (optionally humanized, e.g. InProgress → "In Progress").
Type Parameters
- TEnum
Parameters
- value System.Enum
- humanize System.Boolean = true
EnumName``1(``0 value, System.Boolean humanize) #Formats an enum value for display (optionally humanized).
Parameters
- value ``0
- humanize System.Boolean
public static String Number(Object value, Int32 decimals = 0, CultureInfo culture = null) #StringFormats a numeric value using grouping separators (e.g., "1,234" or "1,234.50").
Parameters
- value System.Decimal
- decimals System.Int32 = 0
- culture System.Globalization.CultureInfo = null
Number(System.Object value, System.Int32 decimals, System.Globalization.CultureInfo culture) #Formats an arbitrary value as a number when possible; otherwise falls back to IFormatProvider).
Parameters
- value System.Object
- decimals System.Int32
- culture System.Globalization.CultureInfo
public static String Percent(Object value, Int32 decimals = 0, CultureInfo culture = null) #StringFormats a percent value (expects percent units, e.g. 12.3 => "12.3%").
Parameters
- percent System.Decimal
- decimals System.Int32 = 0
- culture System.Globalization.CultureInfo = null
Percent(System.Object value, System.Int32 decimals, System.Globalization.CultureInfo culture) #Formats an arbitrary value as percent when possible; otherwise falls back to IFormatProvider). Expects percent units (e.g. 12.3 => "12.3%").
Parameters
- value System.Object
- decimals System.Int32
- culture System.Globalization.CultureInfo
public static String RelativeTime(DateTimeOffset when, DateTimeOffset now) #StringFormats a timestamp relative to now (e.g., "2h ago", "in 3d", "just now").
Parameters
- when System.DateTimeOffset
- now System.DateTimeOffset
public static String Time(DateTimeOffset value, String format = "h:mm tt", CultureInfo culture = null) #StringFormats a time using a short, email-friendly default (e.g., "1:05 PM").
Parameters
- value System.DateTime
- format System.String = "h:mm tt"
- culture System.Globalization.CultureInfo = null
Time(System.DateTimeOffset value, System.String format, System.Globalization.CultureInfo culture) #Formats a time using a short, email-friendly default (e.g., "1:05 PM").
Parameters
- value System.DateTimeOffset
- format System.String
- culture System.Globalization.CultureInfo