开发者

When does a property get called?

I have a confusion on some piece of code开发者_如何转开发.

Inside a class I have a property

Class A
{
  ClassB objB;

  public int TimedValue
  {
    objB.Timer;
  }
}

Inside classB I have

classB
{
 public int Timer
 {
  get
  {
   // get time value using some algorithm....
  }
 }
}

My confusion is that I place breakpoints inside the getters, but I dont see the program flow there and stop! Although I see an object being created and full populated with the TimedValue when I look at it in debug mode inside a watch window. Am I missing something on properties?

EDIT: So, ColinE guided me through the right steps, except I could not find the option there. Here is the screen shot where of where it was suppose to be,

When does a property get called?

My screen shot

When does a property get called?

I guess this is a VS bug. Anyway Just posted this so that anyone with team system 2008 should make a note of this :)


Typically the debugger is configures to step over properties, so your breakpoint will never be 'hit. Ensure that the following checkbox is not checked:

Tools => Options => Debugging => General => Step over properties and operators


It looks like you're accessing the Field Time (if that's not a typo in your question and you've omitted that part in your post), not the property Timer on classB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜