+ 1

Can you explain me the step by step process in this?

Encapsulation using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class BankAccount { private double balance=0; public void Deposit(double n) { balance += n; } public void Withdraw(double n) { balance -= n; } public double GetBalance() { return balance; } } class Program { static void Main(string[] args) { BankAccount b = new BankAccount(); b.Deposit(199); b.Withdraw(42); Console.WriteLine(b.GetBalance()); } } }

11th Oct 2020, 5:05 AM
Yuexue
Yuexue - avatar
1 ответ
+ 1
You create a b object from the class BankAccount.Then you can access the two public function Deposit() and Withdraw() to modify the private variable balance value.Finally you display the final value of balance 167.
11th Oct 2020, 11:36 AM
HBhZ_C
HBhZ_C - avatar