Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Class BankAccount - with two constructors.Lecture 5 - slide 10 : 29
Program 4
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.