c# - Add event handler during object initialization -
I need a certain type of example (which will be made in this moment) for the method, there are several events in this type Which I would also like to subscribe to, so my code looks like this:
var instance = new instance (); Example.OnEvent1 + = (Sender, Args) = & gt; {Do this (;); do that(); } Example.OnEvent2 + = (Sender, Args) = & gt; DoThisToo (); Example: Onewind 3 ... MyMthi (example); Now, it is possible to add handlers during initial time? So I can write something like this:
MyMethod (MyType) Example = & gt; {Instance.OnEvent1 + = (Sender, Args) = & gt; {DoThis (); DoThat (); } Example.OnEvent2 ...}); It is desirable because of cosmetic reasons. I would like to shorten my code & amp; Readable.
It is not possible now, but according to this plan is planned and may be available in the future. --------------------------------------- - ---------------------------------- | Feature | Example | C # | -------------------------------------------------- ----------------------- | | Event Initial | New Customer {Notify = MyHandler}; | Employed | -------------------------------------------------- ----------------------- |
Comments
Post a Comment