Back to notes -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Legal use of constants and readonly variables.Lecture 3 - slide 18 : 29
Program 1
using System;

class ConstDemo {
  const double    ca = 5.0,      
                  cb = ca + 1;   

  private readonly double roa = 7.0,     
                          rob = Math.Log(Math.E);  

  private readonly BankAccount
                  roba = new BankAccount("Anders");

  public ConstDemo(){   // CONSTRUCTOR
    roa = 8.0;   
    roba = new BankAccount("Tim");  
  }                                 

  public static void Main(){
    ConstDemo self = new ConstDemo();  
    self.Go(); 
  }

  public void Go(){
    roba.Deposit(100.0M);  
  }
}
 
 
 
ca is a constant. Symbolic name of 5.0.
cb is a constant. Symbolic name of 6.0.
 
roa is a read-only variable.
rob is also a read-only variable.
 
 
 
 
 
8.0 becomes the final value of roa.
Tim's bank account becomes the
final value of roba.