view Chronosv2/source/Extensions/IntExtensions.cs @ 19:09d18d6e5f40

airport work
author stevenh7776 stevenhollidge@hotmail.com
date Thu, 15 Mar 2012 06:59:15 +0000
parents 443821e55f06
children
line wrap: on
line source

using System;

namespace Chronos.Extensions
{
    /// <summary>
    /// Extension methods for the string data type
    /// </summary>
    public static class IntExtensions
    {
        #region · Extensions ·

        /// <summary>
        /// Performs the specified action n times based on the underlying int value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="action">The action.</param>
        public static void Times(this int value, Action action)
        {
            for (var i = 0; i < value; i++)
            {
                action();
            }
        }

        /// <summary>
        /// Performs the specified action n times based on the underlying int value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="action">The action.</param>
        public static void Times(this int value, Action<int> action)
        {
            for (var i = 0; i < value; i++)
            {
                action(i);
            }
        }

        #endregion
    }
}