Advertisement
d0ntth1nc

Untitled

Jan 10th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. public class Student
  2.     {
  3.         private string name;
  4.         private int age;
  5.  
  6.         // This is just a template.
  7.         public delegate void PropertyChangedHandler(PropertyChangedEventArgs args);
  8.  
  9.         // Our public event( array of methods, functions...), based on our template!
  10.         public event PropertyChangedHandler OnPropertyChanged;
  11.  
  12.         public Student () { }
  13.  
  14.         public string Name
  15.         {
  16.             get { return this.name; }
  17.             set
  18.             {
  19.                 // Our template accepts instance of class "PropertyChangedEventArgs"
  20.                 // Create instance and pass it to the event
  21.                 var eventArgs = new PropertyChangedEventArgs ("name", this.name, value);
  22.  
  23.                 this.name = value;
  24.                 OnPropertyChanged (eventArgs);
  25.             }
  26.         }
  27.  
  28.         public int Age
  29.         {
  30.             get { return this.age; }
  31.             set
  32.             {
  33.                 // Our template accepts instance of class "PropertyChangedEventArgs"
  34.                 // Create instance and pass it to the event
  35.                 var eventArgs = new PropertyChangedEventArgs ("age", this.age, value);
  36.  
  37.                 this.age = value;
  38.                 OnPropertyChanged (eventArgs);
  39.             }
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement