裏口からのC#実践入門

2-11 ループとロジックが入り交じっている

これは・・・、わかりづらいね。

using System;
using System.Linq;

namespace Uraguchi.Scene2
{
    public class Tenshi11
    {
        public static void Run()
        {
            int[] ar = { 5, 2, -1, 1, 4 };
            int[] arWithoutMinus = ar.Where(c => c >= 0).ToArray();
            Console.WriteLine("結果:{0}", arWithoutMinus.Select((n, i) =>
                new Tuple<int, int>(n, i)).Aggregate((sum, next) => {
                    var r = sum.Item1 + next.Item1;
                    Console.WriteLine("{0} 番目の処理、現在合計は {1}", next.Item2, r);
                    return new Tuple<int, int>(r, next.Item2);
                }).Item1);
        }
    }
}

http://Tuple(T1, T2) コンストラクター (System) https://msdn.microsoft.com/ja-jp/library/dd267681(v=vs.110).aspx