HomeCSharpC# Error CS1055 – An add or remove accessor expected

C# Error CS1055 – An add or remove accessor expected

C# Error

CS1055 – An add or remove accessor expected

Reason for the Error & Solution

An add or remove accessor expected

If your is not declared as a field, it must define both add and remove accessor functions.

The following sample generates CS1055:

// CS1055.cs  
delegate void del();  
class Test  
{  
   public event del MyEvent  
   {  
      int i;   // CS1055  
      // uncomment accessors and delete previous line to resolve  
      // add  
      // {  
      //    MyEvent += value;  
      // }  
      // remove  
      // {  
      //    MyEvent -= value;  
      // }  
   }  
  
   public static void Main()  
   {  
   }  
}  

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...