using System;
public class BankAccount{
// automatic generation of private instance variables
public BankAccount(): this("NN") {
}
public BankAccount(string owner){
this.Balance = 0;
this.Owner = owner;
}
public string Owner {get; set;}
public decimal Balance {get; set;}
public override string ToString(){
return Owner + "'s account holds " + Balance + " kroner";
}
} | |
The parameterless constructor.
Here programmed explicitly. Could
alternatively be provided implicitly.
A constructor with one parameter.
The default value of Balance is 0.
The default owner is the one passed
as the first parameter.
An automatic property.
Another automatic property.
Refers to property getters.
The instance variables are anonymous.
|