![]() 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() (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) 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |