c# - Event Handler issue -


i found code online c#. used telerik code converter convert vb.net. getting error below code

closed declared 'public closed(sender object, e system.eventargs)' in class.

same error happens shown well. have ideas fix?

 #region "events"     public event closed eventhandler     public event shown eventhandler      protected overridable sub closed(e eventargs)         dim handler eventhandler = closed          raiseevent handler(me, e)     end sub      protected overridable sub shown(e eventargs)         dim handler eventhandler = shown          raiseevent handler(me, e)     end sub #end region 

here c# code converted vb.

#region events     public event eventhandler closed;     public event eventhandler shown;      protected virtual void closed(eventargs e)     {         eventhandler handler = closed;          if (handler != null) handler(this, e);     }      protected virtual void shown(eventargs e)     {         eventhandler handler = shown;          if (handler != null) handler(this, e);     }     #endregion 

there 2 problems here.

first, if using winforms, system.windows.forms has closed event conflicts event creating. if shadowing intended must shadow event declaring shadows. if declaring in normal class (which doesn't derive form) need not worry it.

public shadows event closed eventhandler public shadows event shown eventhandler 

second, property name , event name cannot same. vb.net case-insensitive in matter. should refactor names follows.

public event closed eventhandler public event shown eventhandler  protected overridable sub whenclosed(byval e eventargs)     raiseevent closed(me, e) end sub  protected overridable sub whenshown(byval e eventargs)     raiseevent shown(me, e) end sub 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -