Reputation:
I don't understand this, please help. Here is my code:
Class MyCookie
Private _CookieName As String
ReadOnly Property CookieName As String
Get
If String.IsNullOrWhiteSpace(_CookieName) Then _CookieName = "Test"
Return _CookieName
End Get
End Property
End Class
I put a breakpoint inside the property Get procedure. When I initialise MyCookie class, MyCookie.CookieName already has "Test" in it but the breakpoint is never hit!
What am I missing?
Upvotes: 0
Views: 207
Reputation: 54417
What other value would the debugger display for that property? The debugger has to execute the property to get a value to display in the IDE but your application hasn't executed the property so the breakpoint isn't activated. Breakpoints are only activated by YOU executing the code, not the IDE. If you were to use the debugger to watch the _CookieName
field instead of the CookieName
property then you'd see exactly what you would expect to see.
Upvotes: 2