=== C# 7.3 ===
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSLear
{
class Program
static void Main(string[] args)
IEnumerable<int> TripleDigit = SeqGen(101, 100, x => x + 1);
Console.WriteLine($"Sum: {SeqSum(TripleDigit, x => x % 7 == 0)}");
Console.ReadKey();
}
public static int SeqSum(IEnumerable<int> Seq, Func<int, bool> Filter)
int Sum = 0;
foreach(var item in Seq)
if (Filter(item)) Sum += item;
return Sum;
public static IEnumerable<T> SeqGen<T>(int n, T first, Func<T, T> next)
yield return first;
T cur = first;
for (int seqlen = 0; seqlen < n - 1; seqlen++)
cur = next(cur);
yield return cur;
=== C# 7.3 ===
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSLear
{
class Program
{
static void Main(string[] args)
{
IEnumerable<int> TripleDigit = SeqGen(101, 100, x => x + 1);
Console.WriteLine($"Sum: {SeqSum(TripleDigit, x => x % 7 == 0)}");
Console.ReadKey();
}
public static int SeqSum(IEnumerable<int> Seq, Func<int, bool> Filter)
{
int Sum = 0;
foreach(var item in Seq)
{
if (Filter(item)) Sum += item;
}
return Sum;
}
public static IEnumerable<T> SeqGen<T>(int n, T first, Func<T, T> next)
{
yield return first;
T cur = first;
for (int seqlen = 0; seqlen < n - 1; seqlen++)
{
cur = next(cur);
yield return cur;
}
}
}
}