Use constructor to set bank account balance.
Ready — edit the code above and click Run.
using System;
class Program
{
static void Main()
{
var acc = new BankAccount(1000);
Console.WriteLine(acc.Balance);
class BankAccount {
public decimal Balance { get; }
public BankAccount(decimal initial) => Balance = initial;
}
}
}
Try solving on your own first, then reveal the official answer.
Constructor initializes object state—core OOP concept.