C#, Making Events?
Ok, i need to do one of two things.
1.) Make my own event system. I have a "Wrapper" that holds some TCP data in it. It has events and whatnot already inside of it, how can i give my class the ability to use events to trigger defined functions outside of the Wrapper Class?
2.) Just as the same as the first one, but im just looking at it dif. Is it possible to "assign" a function to a class? In otherwords, give the class a "function variable", where it holds a reference to a function. When you run the class you give that reference variable a function you want to be triggered, and all is well..
So ya.. im just trying to figure how to make an event based class, as it is important to my code.
Any help would be awesome, thanks!
You can do both.
You can have events in a class that you can fire and hope someone is attached to it :D Or you can have an explicit function pointer where you can call one function.
Look up the delegate keyword. You can declare a delegate which is a definition of a function. You can then save functions in a variable of that type and call them.
You can also have events that are declared to be of a type of one of your delegates. Other classes can then consume these events.