示例#1
0
        static void Main()
        {
            RTransaction tr1 = new RTransaction
            {
                From = "Alice", To = "Bob", Amount = 100
            };

            RTransaction tr2 = new RTransaction
            {
                From = "Alice", To = "Charlie", Amount = 100
            };

            Console.WriteLine(tr1);
            Console.WriteLine(tr2);
        }
示例#2
0
        static void Main(string[] args)
        {
            RTransaction tr1 = new RTransaction
            {
                From   = "Alice",
                To     = "Bob",
                Amount = 100
            };

            RTransaction tr2 = new RTransaction
            {
                From   = "Alice",
                To     = "Charlie",
                Amount = 100
            };

            WriteLine(tr1);
            WriteLine(tr2);
        }
示例#3
0
        static void Main(string[] args)
        {
            RTransaction tr1 = new RTransaction {
                From = "Alice", To = "Bob", Amount = 100
            };
            //with를 이용해서 DeepCopy를 할 수 있음
            RTransaction tr2 = tr1 with {
                To = "Charlie"
            };
            RTransaction tr3 = tr2 with {
                From = "Dave", Amount = 30
            };

            WriteLine(tr1);
            WriteLine(tr2);
            WriteLine(tr3);
        }
    }
}
示例#4
0
        static void Main(string[] args)
        {
            RTransaction tr1 = new RTransaction
            {
                From   = "Alice",
                To     = "Bob",
                Amount = 100
            };

            RTransaction tr2 = tr1 with {
                To = "Charlie"
            };                                              // with 연산자를 프로퍼티 입력을 반복하지 않아 편리하다.
            RTransaction tr3 = tr2 with {
                From = "Dave", Amount = 30
            };

            Console.WriteLine(tr1);
            Console.WriteLine(tr2);
            Console.WriteLine(tr3);
        }
    }
}