Extensions/IntegerExtensions.cs
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ComLib.Extensions
{
/// <summary>
/// Extension classes for integers.
/// </summary>
public static class IntegerExtensions
{
#region Loops
/// <summary>
/// Iterates the action using a for loop from 0 to ndx.
/// </summary>
/// <param name="ndx">The number of times to iterate ( 0 based )</param>
/// <param name="action">The action to call</param>
public static void Times(this int ndx, Action<int> action)
{
for (int i = 0; i < ndx; i++)
{
action(i);
}
}
/// <summary>
/// Iterates over the action from the start to the end non-inclusive.
/// </summary>
/// <param name="start">The starting number.</param>
/// <param name="end">The ending number ( non-inclusive )</param>
/// <param name="action">Action to call.</param>
public static void Upto(this int start, int end, Action<int> action)
{
for (int i = start; i <= end; i++)
{
action(i);
}
}
/// <summary>
/// Iterates over the action from start to end including the end number.
/// </summary>
/// <param name="start">The starting number.</param>
/// <param name="end">The ending number ( inclusive )</param>
/// <param name="action">Action to call.</param>
public static void UptoIncluding(this int start, int end, Action<int> action)
{
for (int i = start; i <= end; i++)
{
action(i);
}
}
/// <summary>
/// Iterates over the action from the end to the start non-inclusive.
/// </summary>
后面还有 328 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
