Lecture overview -- Keyboard shortcut: 'u'  Previous page: Properties - Basic Use -- Keyboard shortcut: 'p'  Next page: Properties in C# -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Page 6 : 29
Object-oriented Programming in C#
Data Access, Properties, and Methods
Properties - Tricky Use

public class C {
  
  private int v;

  public C(int t){
    v = t;
  }

  public int V {
    get  {return v * 2;}
    set  {v = value + 3;}
  }  
}

A Class C with a simple properties - getter and setter.

using System;
public class Client {

  public static void Main(){

    C x = new C(5);

    x.V = 7;                  // activates setter: v is assigned to ?
    Console.WriteLine(x.V);   // activates getter: output ?
  }

}

A client of class C.