f0f1f2.studio Template reference
English
Open application
Method

FormatPercent

Definition

Namespace
Resto.Front.PrintTemplates.Cheques.Razor

Formats a percentage value and appends a percent sign.

string TemplateBaseCore<T>.FormatPercent(decimal value)
Returns
string
Nullability
Not specified
Declared in
Resto.Front.PrintTemplates.Cheques.Razor.TemplateBaseCore<T>
Model purpose
Base class for RazorEngineCore print templates. Model contains the document data of type T. Provides formatting and markup output methods.

Parameters

decimal value
Percentage points, such as 12.5 for 12.5%; not a fraction of one.

Return value

An integer percentage or a percentage with two decimal places.

Remarks

Does not multiply by 100. Checks whether Decimal.Round(value, 2) is integral, then formats the original value with f0 or f2 and appends %. Uses CurrentCulture.

Example

// en-GB
FormatPercent(12m); // "12%"
FormatPercent(12.5m); // "12.50%"
FormatPercent(0.12m); // "0.12%"