3 ms·
It's a real library I wrote. I just noticed I missed the brackets. Quick example you can infer the rest from: Code: public static class IntegerExtensions
by togusa 11y ago
It's a real library I wrote. I just noticed I missed the brackets. Quick example you can infer the rest from:
Code:
public static class IntegerExtensions
{
public static TimeSpan Minutes(this int val)
{
return TimeSpan.FromMinutes(val);
}
}
Usage examples I can think of:
var eightMinutes = 8.Minutes();
var tenMinutes = 8.Minutes() + 2.Minutes();
DoSomethingEvery(8.Minutes());
- gregmac 11y agoYeah I figured. Is it published/OSS?
- togusa 11y agoNot at the moment. I've got a ton of stuff I probably could publish however.
- jmcqk6 11y agoJust a note, because I started in the same way you have, simply writing my own extension methods in a common dll. The Humanizer library has a bunch of these features, including the 6.minutes() functionality: https://github.com/MehdiK/Humanizer https://github.com/MehdiK/Humanizer