
"this is a test".SetCase(CaseOption.Capitalize) Or you can pass a CaseOption parameter to SetCase(). You can use any of the individual methods SetUpperCase(), SetLowerCase(), Capitalize() or SetTitleCase(). Wordify contains several extension methods for setting case of a string. You can use the Wordify.AddIrregularNoun() and Wordify.AddDefectiveNoun() methods to add additional words that require special handling by the pluralizer. It is just not possible for the library to handle every word perfectly. Note that the English language is complex. This method pluralizes the string only when the numeric value is not equal to 1. CodeĪnother variation of the Pluralize() method accepts a numeric argument. CodeĪnd use the Singularize() extension method to make a plural word singular. Use the Pluralize() extension method to make a word plural. The library also provides support for making words plural and then back to singular again. The examples below assuming the following enum. This Wordify() extension method takes an optional bool argument that, when set to true, will prevent this method from checking for the presence of a DescriptionAttribute. Otherwise, the name of the enum is passed to the Wordify() extension method described above. If the enum value has a DescriptionAttribute attribute, the method returns the description from that attribute. Wordifying Enumsįinally, there is a variation of the Wordify() method specifically for enums. That's just a limitation of word detection from camel case. Notice in the last example that there is no way to detect if IBM and XT should be separate words. "IBoughtAnOldIBMXT".InsertCamelCaseSpaces() "TheHTTPProtocol".InsertCamelCaseSpaces() If you know your string contains camel case, you can call the InsertCamelCaseSpaces() extension method directly. "abc-def".Wordify(WordifyOption.ReplaceHypens) "abc-def".Wordify(WordifyOption.AutoDetect) "abc_def".Wordify(WordifyOption.AutoDetect) Otherwise, you can pass WordifyOption.AutoDetect and Wordify() will attempt to automatically detect the type of transformation needed. If you know what method should be used for your string, you can achieve a small performance gain by passing the appropriate WordifyOption option. The examples below use the Wordify() extension method. SoftCircuits.Wordify has several methods to help convert symbol names like TotalCount, total_count and total-count to text like total count. New TimeSpan(4, 7, 44).Wordify(3, DateTimeOption.UseWords) įour hours, seven minutes and forty-four seconds Pass a larger number to include additional parts. By default, the precision is 1, and only one part of the time span will be described. This method also takes a precision argument. Here are examples using the version of Wordify() for TimeSpan values. Now.AddHours(-2).AddMinutes(-24).Wordify(DateTimeOption.UseWords) Now.AddHours(2).AddMinutes(24).Wordify()
#Wordify extracted keyword code
(Note that when using the version that automatically gets the current date and time, that it's possible to have a couple of milliseconds pass before it does.) Code The following examples assume a DateTime variable with the name now.

Or, you can supply your own date and time that the description should be relative to. This version of Wordify() describes the relationship between the specified date and time with the current date and time. The library also provides support for describing the differences between two DateTime values.

The MakeOrdinalDigits() extension method works similarly but outputs digits instead of words.

The library also has support for converting numbers to ordinals using the MakeOrdinal() extention method. For example: 123.67.Wordify(FractionOption.Decimal).Capitalize(). Note: Because most of these methods return strings, it's easy to chain extension method calls. Three hundred forty-five dollars and sixty-seven cents Three hundred forty-five and sixty-seven one hundredthsģ45.67.Wordify(FractionOption.UsCurrency)
#Wordify extracted keyword how to
The one that accepts floating point values also takes a FractionOption argument that specifies how to format the fractional part. The library can be used to convert numbers to words. And all methods that return a string ensure the return value is never null. Note: Wordify methods that accept a string parameter always correctly handle when that parameter is null. It includes methods to convert numbers and dates to text, insert spaces into camel-case strings, pluralize strings, truncate strings, convert Roman numerals, create memory size strings and much more. Wordify is a static class that contains extension methods to create and modify text.
