Skip to main content
Version: 3.0.10 (latest)

Humanizer.CasingExtensions

CasingExtensions Class

ApplyCase method to allow changing the case of a sentence easily

public static class CasingExtensions

Inheritance System.Object → CasingExtensions

Methods

CasingExtensions.ApplyCase(this string, LetterCasing) Method

Applies the specified letter casing transformation to the input string.

public static string ApplyCase(this string input, Humanizer.LetterCasing casing);

Parameters

input System.String

The string to transform. Must not be null.

casing LetterCasing

The desired letter casing style to apply to the input string.

Returns

System.String
A new string with the specified casing applied. - Title: Each word is capitalized (e.g., "Some String") - LowerCase: All letters are lowercase (e.g., "some string") - AllCaps: All letters are uppercase (e.g., "SOME STRING") - Sentence: First letter capitalized, rest lowercase (e.g., "Some string")

Exceptions

System.ArgumentOutOfRangeException
Thrown when an invalid LetterCasing value is provided.

Example

"some string".ApplyCase(LetterCasing.Title) => "Some String"
"SOME STRING".ApplyCase(LetterCasing.LowerCase) => "some string"
"some string".ApplyCase(LetterCasing.AllCaps) => "SOME STRING"
"some string".ApplyCase(LetterCasing.Sentence) => "Some string"