program.cs

来自「C#高级编程第6版随书源代码 值得下载」· CS 代码 · 共 36 行

CS
36
字号
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wrox.ProCSharp.Generics
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Account> accounts = new List<Account>();
            accounts.Add(new Account("Christian", 1500));
            accounts.Add(new Account("Sharon", 2200));
            accounts.Add(new Account("Katie", 1800));

            decimal amount = Algorithm.AccumulateSimple(accounts);

            decimal amount2 = Algorithm.Accumulate(accounts);

            decimal amount3 = Algorithm.Accumulate<Account, decimal>(
                accounts, 
                delegate(Account a, decimal d)
                { return a.Balance + d; });

            decimal amount4 = Algorithm.Accumulate<Account, decimal>(
                accounts, (a, d) => a.Balance + d);

            decimal amount5 = Algorithm.AccumulateIf<Account, decimal>(
               accounts, (a, d) => a.Balance + d, a => a.Balance > 2000);


        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?