Do I have to encode Console.ReadLine() in the Main method? | SoloLearn: Learn to code for FREE!

0

Do I have to encode Console.ReadLine() in the Main method?

Here are some codes from the Encapsulation lesson. ---------------- 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()); } } ‐------‐---- I want to determine the Deposit and Withdrawal through a user-input. How do I do that?

9/9/2019 2:03:45 AM

aykut

1 Answer

New Answer

+1

Yes, I believe you should use Console.ReadLine(), to accept input from the user and pass that input to the methods you want,