view MetroWpf/MetroWpf.Framework/Extensions/IntExtensions.cs @ 89:3c67e54e3a17

Working version
author stevenhollidge <stevenhollidge@hotmail.com>
date Mon, 30 Apr 2012 10:45:32 +0100
parents 060f02cd4591
children
line wrap: on
line source

using System;

namespace MetroWpf
{
    /// <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
    }
}