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,
My screen shot
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
.
精彩评论