Search code examples
c#unused-variables

How to prevent getting warning of unused variable implementation of an abstract class


I have an abstract class which has an event (abstract). I do not need actually this event in my implementation. When I dont use it in my implementation, it gives well warning, which I dont want to have.. Is there any c# predefine annotation like [unused] or [ignore] to prevent getting warning?

public abstract class Abc
{
 ...
 public abstract event EventHandler<MsgEventHandler> 
}

public MyClass: Abc
{
   public override event EventHandler<MsgEventHandler> MesReceived;


//constructers
//methodes
//etc

}

Solution

  • Add

    #pragma warning disable 0067
    

    before the declaration of the abstract event handler. Do not forget to restore it. This should probably work for you:

    public class MyClass: Abc
    {
    #pragma warning disable 0067
        public override event EventHandler<EventArgs> MesReceived;
    #pragma warning restore 0067
    }