> For the complete documentation index, see [llms.txt](https://docs-siticoneframework.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-siticoneframework.gitbook.io/home/net-framework-or-net-core-ui/data-formatting-and-display/siticone-humanizerdec../customizable-humanization.md).

# Customizable Humanization

## Overview

The Customizable Humanization feature is provided via the `GetHumanizedValue` method, which extends the basic humanization functionality by enabling custom control over the number of decimal places and the cultural format used. This feature is particularly useful when the default two-decimal-place precision or invariant culture formatting does not meet specific application requirements, allowing for greater flexibility in how numerical values are presented.

***

### Key Points

<table><thead><tr><th width="173">Aspect</th><th>Details</th></tr></thead><tbody><tr><td>Method Name</td><td>GetHumanizedValue</td></tr><tr><td>Return Type</td><td>string</td></tr><tr><td>Parameters</td><td><code>int decimalPlaces = 2</code>, <code>CultureInfo culture = null</code></td></tr><tr><td>Purpose</td><td>Provides a customized humanized representation of the <code>Value</code> property with adjustable formatting settings.</td></tr><tr><td>Default Values</td><td>2 decimal places and <code>CultureInfo.InvariantCulture</code> if no culture is provided.</td></tr></tbody></table>

***

### Best Practices

<table><thead><tr><th width="258">Aspect</th><th>Recommendation</th></tr></thead><tbody><tr><td>Custom Precision</td><td>Use the <code>decimalPlaces</code> parameter to set precision that matches the application's data display needs.</td></tr><tr><td>Culture-Specific Formatting</td><td>Provide a specific <code>CultureInfo</code> if the default invariant culture does not suit regional formatting requirements.</td></tr><tr><td>Validate Inputs</td><td>Always validate the inputs, ensuring that <code>decimalPlaces</code> is not negative before calling the method.</td></tr><tr><td>Consistency in UI</td><td>Use the method consistently across the application to maintain uniform formatting of numeric displays.</td></tr></tbody></table>

***

### Common Pitfalls

| Pitfall                    | Description                                                                                                  | Recommendation                                                                          |
| -------------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
| Negative Decimal Places    | Passing a negative value for `decimalPlaces` results in an `ArgumentException`.                              | Ensure that the `decimalPlaces` parameter is always a non-negative integer.             |
| Ignoring Culture Parameter | Relying solely on the default culture may lead to formatting issues in localized applications.               | Specify a `CultureInfo` instance when necessary to match regional settings.             |
| Overuse of Customization   | Excessive customization may lead to inconsistent formatting across the application if not managed carefully. | Standardize the usage of formatting settings in a central configuration where possible. |

***

### Usage Scenarios

| Scenario                                     | Description                                                                            | Example Code Sample                                                                                                                                                                                                                                                                                                                                                         |
| -------------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Custom Precision Display                     | Formatting numbers to show more or fewer decimal places than the default.              | `csharp<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 1234567m;<br>string formatted = humanizer.GetHumanizedValue(decimalPlaces: 4);<br>Console.WriteLine("Formatted Value: " + formatted);<br>`                                                                                                                                                  |
| Localization in International Applications   | Adapting number formatting to different regional settings using specific culture info. | `csharp<br>using System.Globalization;<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 9876543m;<br>string formatted = humanizer.GetHumanizedValue(decimalPlaces: 3, culture: new CultureInfo("de-DE"));<br>Console.WriteLine("Localized Value: " + formatted);<br>`                                                                                |
| Dynamic Formatting Based on User Preferences | Allowing users to set their preferred numeric precision in the application settings.   | `csharp<br>// Assume userPreferenceDecimalPlaces is obtained from a settings menu<br>int userPreferenceDecimalPlaces = 1;<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 2500000m;<br>string formatted = humanizer.GetHumanizedValue(decimalPlaces: userPreferenceDecimalPlaces);<br>Console.WriteLine("User Formatted Value: " + formatted);<br>` |

***

### Real Life Usage Scenarios

| Scenario                     | Description                                                                                                 | Example Code Sample                                                                                                                                                                                                                                                           |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Financial Reporting          | Presenting financial figures with the precise decimal formatting required by accounting standards.          | `csharp<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 1250000m;<br>string reportValue = humanizer.GetHumanizedValue(decimalPlaces: 2, culture: new CultureInfo("en-US"));<br>Console.WriteLine("Financial Report: " + reportValue);<br>`            |
| Scientific Data Presentation | Displaying measurement data where precision is critical, such as in scientific or engineering applications. | `csharp<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 0.0001234567m;<br>string preciseValue = humanizer.GetHumanizedValue(decimalPlaces: 8, culture: CultureInfo.InvariantCulture);<br>Console.WriteLine("Scientific Value: " + preciseValue);<br>` |
| E-commerce Analytics         | Tailoring the display of sales figures or website metrics to suit international audiences.                  | `csharp<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 1034500m;<br>string localizedValue = humanizer.GetHumanizedValue(decimalPlaces: 2, culture: new CultureInfo("fr-FR"));<br>Console.WriteLine("E-commerce Metrics: " + localizedValue);<br>`    |

***

### Troubleshooting Tips

| Issue                       | Possible Cause                                                                                    | Suggested Resolution                                                                       |
| --------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Incorrect Formatting        | The `decimalPlaces` parameter might be set incorrectly or an inappropriate `CultureInfo` is used. | Verify that the parameters are correct and use a culture that matches the expected output. |
| Argument Exceptions         | Passing negative values for `decimalPlaces` triggers an exception.                                | Ensure input validation is performed before calling `GetHumanizedValue`.                   |
| Inconsistent Number Display | Using different parameters across various parts of the application can lead to inconsistencies.   | Standardize the formatting configuration across the application to ensure consistency.     |

***

### Review

<table><thead><tr><th width="216">Aspect</th><th>Notes</th></tr></thead><tbody><tr><td>Flexibility</td><td>The method offers great flexibility, allowing developers to tailor the output to their specific needs.</td></tr><tr><td>Ease of Integration</td><td>Simple method call with optional parameters makes it easy to integrate into existing code.</td></tr><tr><td>Customization Impact</td><td>Enhanced control over number formatting improves the overall presentation and user experience.</td></tr></tbody></table>

***

### Summary

<table><thead><tr><th width="185">Aspect</th><th>Summary</th></tr></thead><tbody><tr><td>Purpose</td><td>The Customizable Humanization feature refines the output of the humanized value by allowing custom decimal precision and culture-specific formatting.</td></tr><tr><td>Key Benefit</td><td>It provides developers with precise control over numeric presentation, essential for applications requiring high accuracy or localized formats.</td></tr><tr><td>Integration Ease</td><td>Easily integrated into .NET WinForms applications via the <code>GetHumanizedValue</code> method.</td></tr><tr><td>Developer Impact</td><td>Simplifies the process of adapting number formatting to different contexts, enhancing both readability and usability.</td></tr></tbody></table>

***

### Additional Code Examples

#### Example 1: Custom Precision and Default Culture

```csharp
using System;
using SiticoneNetFrameworkUI;

class Program
{
    static void Main()
    {
        var humanizer = new SiticoneHumanizerDecimal();
        humanizer.Value = 1234567m;

        // Customizing to display with 4 decimal places
        string customFormatted = humanizer.GetHumanizedValue(decimalPlaces: 4);
        Console.WriteLine("Custom Formatted Value: " + customFormatted);
        // Example output: "1.2345M" (depending on the value)
    }
}
```

#### Example 2: Custom Culture Formatting

```csharp
using System;
using System.Globalization;
using SiticoneNetFrameworkUI;

class Program
{
    static void Main()
    {
        var humanizer = new SiticoneHumanizerDecimal();
        humanizer.Value = 9876543m;

        // Specifying German culture for formatting
        string localizedFormatted = humanizer.GetHumanizedValue(decimalPlaces: 3, culture: new CultureInfo("de-DE"));
        Console.WriteLine("Localized Formatted Value: " + localizedFormatted);
        // Example output: "9,876M" (depending on the value and culture-specific formatting)
    }
}
```

#### Example 3: Dynamic Formatting Based on User Preferences

```csharp
using System;
using SiticoneNetFrameworkUI;

class Program
{
    static void Main()
    {
        // Simulated user setting for decimal places
        int userPreferredDecimalPlaces = 1;
        var humanizer = new SiticoneHumanizerDecimal();
        humanizer.Value = 2500000m;

        // Formatting based on user preference
        string userFormatted = humanizer.GetHumanizedValue(decimalPlaces: userPreferredDecimalPlaces);
        Console.WriteLine("User Formatted Value: " + userFormatted);
        // Example output: "2.5M"
    }
}
```

***

By following this comprehensive documentation, developers can effectively utilize the Customizable Humanization feature to tailor the display of large numeric values to meet specific formatting requirements and regional preferences, ensuring optimal clarity and consistency in their .NET WinForms applications.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-siticoneframework.gitbook.io/home/net-framework-or-net-core-ui/data-formatting-and-display/siticone-humanizerdec../customizable-humanization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
