An equivalent client of class BankAccount without object initializers. | Lecture 5 - slide 10 : 29 Program 6 |
using System; public class Client { public static void Main(){ BankAccount ba1 = new BankAccount(); ba1.Owner = "James"; ba1.Balance = 250; BankAccount ba2 = new BankAccount("Bill"); ba2.Balance = 1200; Console.WriteLine(ba1); Console.WriteLine(ba2); } } | This version of class Client shows how the compiler deals with object initializers. Use of setters to initialize the owner and the balance of the account after the activation of the constructor. |