Lesson 14: Introduction to Delegates and Events
Is it possible in C to connect one event to another so emitting first event will emit second one? The only way i can see is to create a stub function that will emit second event and connect the first event to hook up event c# function. Maybe it's some decorator available or some black magic that allows to chain events without stub functions? You cannot do this, because you generally cannot do anything to an event from outside the object which owns it except for adding and removing handlers. In particular, you cannot list the existing registered handlers, and you cannot raise it.
In your case, "copying" the event is essentially the same thing in disguise, and would allow you to circumvent this restriction; therefore, it's not allowed. See this recent answer of mine for a more in-depth explanation of why things are the way they are - I just don't feel like retyping it all here. For your particular case, if you own both classes, the workaround is to make them cooperate specifically - make Ui be aware of the associated Logic instance, and add event handlers to Logic.
Stack Overflow Hook up event c# Explore Jobs Documentation beta Tags Users. Sign up or log in to customize your list. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.
Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it hook up event c# takes a minute: Subscribe event to event in C? Eye of Hell 8, 34 That's precisely the point. List of handlers is private to the object which owns the event, by design. Hook up event c# reason is that object alone hook up event c# control when and how the handlers are invoked. If you dating for transwomen to break encapsulation, you'll need to provide a special hatch for it, and your classes need to be aware of it - hence coupling.
What you're asking for is really hook up event c# different from "can I access the private field of one of my classes from another? So basically all i need to do is to move the subscription code into a class that owns the second event? Not sure which one of them is second: I have checked that on VS with. JaredPar k 91 The same logic works though between two objects if they are otherwise connected. Sign up or log in StackExchange. Sign up using Facebook.