Caller Information Example (C# 5.0)

Well, just a quick reference mainly to myself about using this new feature for INotifyPropertyChanged where most of the time I had to implement this using reflection. Notice the propertyName is filled in by the compiler


public class ViewModelBase : INotifyPropertyChanged {

  protected void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = "") {
    if (!Object.Equals(field, value)) {
      field = value;
public class SomeControl : ViewModelBase {
  private int _someInt;
  public int SomeInt {
    get { return _someInt; }
    set { Set(ref _someInt, value); }  // Compiler maginc -> fills in "SomeInt" as propertyName


if this post is malformed then go here