コード例 #1
0
ファイル: Program.cs プロジェクト: GGammu/InsideCSharp
        static void Main(string[] args)
        {
            Invoice i1 = new Invoice();

            for (int i = 0; i < 2; i++)
            {
                i1.DetailLines.Add(new InvoiceDetailLine(i + 1));
            }

            i1.PrintInvoice();

            Invoice i2 = new Invoice();

            for (int i = 0; i < 2; i++)
            {
                i2.DetailLines.Add(new InvoiceDetailLine(i + 1));
            }

            Invoice summaryInvoice = i1 + i2;

            Console.WriteLine("*** Summary Invoice for Invoices 1 & 2 ***");
            summaryInvoice.PrintInvoice();

            Console.ReadLine();
        }
コード例 #2
0
ファイル: Invoice.cs プロジェクト: GGammu/InsideCSharp
        public static Invoice operator +(Invoice invoice1, Invoice invoice2)
        {
            Invoice returnInvoice = new Invoice();

            foreach (InvoiceDetailLine detailLine in invoice1.DetailLines)
            {
                returnInvoice.DetailLines.Add(detailLine);
            }

            foreach (InvoiceDetailLine detailLine in invoice2.DetailLines)
            {
                returnInvoice.DetailLines.Add(detailLine);
            }

            return returnInvoice;
        }