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

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at