Click here to Skip to main content
15,887,421 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
f1
{
 UCPrsnCod.DataAvailable += new EventHandler(UCEnterPrsnlCood_DataAvailable1);
}
f2
{
 UCPrsnCod.DataAvailable += new EventHandler(UCEnterPrsnlCood_DataAvailable2);
}


void UCEnterPrsnlCood_DataAvailable1(object sender, EventArgs e)
{
    UC_EnterPersonelCod shfrm = (UC_EnterPersonelCod)sender;
    if (shfrm != null)
    {
        LoadTimeCrdFrm(shfrm.Data);
    }
}
//--------------------------------------------------
void UCEnterPrsnlCood_DataAvailable2(object sender, EventArgs e)
{
    UC_EnterPersonelCod shfrm = (UC_EnterPersonelCod)sender;
    if (shfrm != null)
    {
        LoadPrsnlInfo(shfrm.Data);
    }
}
Posted
Comments
Krunal Rohit 10-Mar-14 10:11am    
Can you please make it more clear ?

-KR
Sergey Alexandrovich Kryukov 10-Mar-14 10:35am    
This is gibberish, not the code which would compile. Not clear what would you mean by "merge".
—SA

1 solution

If all you do is delegate to another method on your event handler, consider using an anonomyous delegate;

C#
f1 {
 UCPrsnCod.DataAvailable += (s, e) => LoadTimeCrdFrm(((UC_EnterPersonelCod)shfrm).Data);
}

f2 {
  UCPrsnCod.DataAvailable += (s, e) => LoadPrsnlInfo(((UC_EnterPersonelCod)shfrm).Data);
}


Hope this helps,
Fredrik
 
Share this answer
 
v2
Comments
mit62 10-Mar-14 11:00am    
tnx but,the functions in if clauses are different.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900