Skip to main content
Version: 3.0.10 (latest)

Five-minute quick start

Orientation

You will create a console app, install Humanizer 3.0.10, and produce one deterministic duration. Use a .NET SDK that can create a project compatible with the selected package assets.

Example

Create the project and add the selected package:

dotnet new console --name HumanizerQuickStart
cd HumanizerQuickStart
dotnet add package Humanizer --version 3.0.10

Replace Program.cs with the verified source:

Program.cs
using System.Globalization;
using Humanizer;

CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");

var result = TimeSpan.FromMinutes(2).Humanize();
if (result != "2 minutes")
throw new InvalidOperationException($"Unexpected result: {result}");

Console.WriteLine(result);

Run it:

dotnet run

Result

The program prints exactly:

2 minutes

The assertion fails immediately if Humanizer 3.0.10 produces a different value.

Pitfall

Many Humanizer operations use the current culture or UI culture when no culture is supplied. Set both explicitly in examples, tests, background work, and any operation whose output must be predictable.

Version notes

This source is compiled and run against the selected Humanizer 3.0.10 package during documentation validation.