mashinkata mashinkata - 1 year ago 69
C# Question

C# Detect when Pop is called on Stack structure

I'm looking for a way to check when

function is called on my
structure I'm currently using a property with extended setter however
doesn't seems to trigger the setter and I'm pretty much unable to determine when the collection is actually changed unless I'm changing reference itself. Any tips on this one ? Again I only care about the
function I don't really want to know when Push is invoked or anything else that can modify the collection.

Answer Source

You'll have to create your own collection (most likely just wrapping a Stack reference) so that you can create an event and trigger it when a given operation (in this case, any collection change by the sounds of it) is performed. Other than your even logic, you can just create a member for each public member of Stack and have it simply forward the call onto a private Stack instance.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download