Humanizer.ICollectionFormatter
ICollectionFormatter Interface
Formats collections into localized, human-readable lists.
public interface ICollectionFormatter
Remarks
Built-in implementations ignore rendered items that are null, empty, or whitespace after
formatting, and they may trim the surviving values before joining them. They also expect the
input collection and any formatter delegate to be non-null.
Methods
ICollectionFormatter.Humanize<T>(IEnumerable<T>) Method
Formats the collection for display by calling ToString() on each item.
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection);
Type parameters
T
The item type in the collection.
Parameters
collection System.Collections.Generic.IEnumerable<T>
The collection to format.
Returns
System.String
The formatted collection.
Exceptions
System.ArgumentNullException
If collection is null.
ICollectionFormatter.Humanize<T>(IEnumerable<T>, string) Method
Formats the collection for display by calling ToString() on each item and using
separator to join the rendered items.
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, string separator);
Type parameters
T
The item type in the collection.
Parameters
collection System.Collections.Generic.IEnumerable<T>
The collection to format.
separator System.String
The localized separator used to join the rendered items.
Returns
System.String
The formatted collection.
Exceptions
System.ArgumentNullException
If collection is null.
Remarks
Implementations may place the separator before the final item or between every item depending on the list style.
ICollectionFormatter.Humanize<T>(IEnumerable<T>, Func<T,object>) Method
Formats the collection for display by calling objectFormatter on each item.
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T,object?> objectFormatter);
Type parameters
T
The item type in the collection.
Parameters
collection System.Collections.Generic.IEnumerable<T>
The collection to format.
objectFormatter System.Func<T,System.Object>
The formatter used to convert each item into text.
Returns
System.String
The formatted collection.
Exceptions
System.ArgumentNullException
If collection or objectFormatter is null.
ICollectionFormatter.Humanize<T>(IEnumerable<T>, Func<T,object>, string) Method
Formats the collection for display by calling objectFormatter on each item and using separator to join the rendered items.
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T,object?> objectFormatter, string separator);
Type parameters
T
The item type in the collection.
Parameters
collection System.Collections.Generic.IEnumerable<T>
The collection to format.
objectFormatter System.Func<T,System.Object>
The formatter used to convert each item into text.
separator System.String
The localized separator used to join the rendered items.
Returns
System.String
The formatted collection.
Exceptions
System.ArgumentNullException
If collection or objectFormatter is null.
Remarks
Implementations may place the separator before the final item or between every item depending on the list style.
ICollectionFormatter.Humanize<T>(IEnumerable<T>, Func<T,string>) Method
Formats the collection for display by calling objectFormatter on each item.
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T,string?> objectFormatter);
Type parameters
T
The item type in the collection.
Parameters
collection System.Collections.Generic.IEnumerable<T>
The collection to format.
objectFormatter System.Func<T,System.String>
The formatter used to convert each item into text.
Returns
System.String
The formatted collection.
Exceptions
System.ArgumentNullException
If collection or objectFormatter is null.
ICollectionFormatter.Humanize<T>(IEnumerable<T>, Func<T,string>, string) Method
Formats the collection for display by calling objectFormatter on each item and using separator to join the rendered items.
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T,string?> objectFormatter, string separator);
Type parameters
T
The item type in the collection.
Parameters
collection System.Collections.Generic.IEnumerable<T>
The collection to format.
objectFormatter System.Func<T,System.String>
The formatter used to convert each item into text.
separator System.String
The localized separator used to join the rendered items.
Returns
System.String
The formatted collection.
Exceptions
System.ArgumentNullException
If collection or objectFormatter is null.
Remarks
Implementations may place the separator before the final item or between every item depending on the list style.