Binil
Binil

Reputation: 6583

C# - Check which event changed / accessed a Property

I have a class with property say

    private string fieldSelectedItem;
    public string FieldSelectedItem
    {
        get
        {
            return fieldSelectedItem;
        }
        set
        {
            fieldSelectedItem = value;
        }
    }

it is accessed from many place.

I came across a situation that the a property in class is accessed by some event. and also some event is changing the value. i tried debugging. is it possible to check which event/function has changed/accessed the property. is there any method to do so.

Upvotes: 3

Views: 278

Answers (2)

Tim Barrass
Tim Barrass

Reputation: 4939

The stack trace should give you some information about where the call has come from, if you break in the property accessors.

Upvotes: 4

Jamiec
Jamiec

Reputation: 136074

How about placing a breakpoint in the setter and looking at the stack trace.

Simples.

Upvotes: 9

Related Questions