I want to create an event in C# but I'm getting this error:
An unhandled exception of type 'System.NullReferenceException' occurred in shei graii.exe
Additional information: Object reference not set to an instance of an object.
Server code:
public class mobile
{
    public delegate void chargeEvent();
    public event chargeEvent sampleEvent;
    private byte _charge;
    public byte charge
    {
        set
        {
            _charge = value;
            if (_charge <= 15)
            {
                sampleEvent(); // the error line
            }
        }
    }
}
Client code:
mobile mob = new mobile();
mob.charge = 14;
mob.sampleEvent += new mobile.chargeEvent(input);
Input code:
public void input()
{
    MessageBox.Show("battery low");
}
 
     
    