简体   繁体   中英

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.

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

Simples.

如果您在属性访问器中中断,堆栈跟踪应该为您提供有关调用来源的一些信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM