Skip to content

Instantly share code, notes, and snippets.

@txdv
Created November 13, 2012 13:50
Show Gist options
  • Save txdv/4065854 to your computer and use it in GitHub Desktop.
Save txdv/4065854 to your computer and use it in GitHub Desktop.
Times extension for .net numbers
using System;
namespace System
{
public static class TimesExtensions
{
public static void Times(this byte times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this byte times, Action<byte> cb)
{
for (byte i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this sbyte times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this sbyte times, Action<sbyte> cb)
{
for (sbyte i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this short times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this short times, Action<short> cb)
{
for (short i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this ushort times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this ushort times, Action<ushort> cb)
{
for (ushort i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this int times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this int times, Action<int> cb)
{
for (int i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this uint times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this uint times, Action<uint> cb)
{
for (uint i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this long times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this long times, Action<long> cb)
{
for (long i = 0; i < times; i++) {
cb(i);
}
}
public static void Times(this ulong times, Action cb)
{
times.Times((i) => { cb(); });
}
public static void Times(this ulong times, Action<ulong> cb)
{
for (ulong i = 0; i < times; i++) {
cb(i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment