How to generate an own event in a user control


What a good day everyone, diculpen I have the following question, is about how to make a custom event in c # something similar to VB if possible or not in C #

Visual Basic

Public Class Boton

Public Event _Click(ByVal bandera As Boolean)

End Class
asked by Lorenzo Molina 05.03.2018 в 21:18

1 answer


You can use delegates and events

public delegate void RecibidoEventHandler(byte[] body);
public event RecibidoEventHandler Recibido;

Then in your code to execute only "shoot" the event


For the observer / consumer of the event

objetoA.Recibido+= MiClaseDelObjeto_Recibido;

what it does is "point" to the method with the same signature

private async void MiClaseDelObjeto_Recibido(byte[] body){

Link that can help you

answered by 05.03.2018 / 21:59