Use constructor to set bank account balance.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
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.