Compiler Error CS1055
An add or remove accessor expected
If your event 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()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: