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

public class C {
  private int v;

  public C(int t){
    v = t;

  public int V {
    get  {return v;}
    set  {v = value;}

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 7.
    Console.WriteLine(x.V);   // activates getter: output 7.


A client of class C.