Compiler Error CS0068
'event': event in interface cannot have initializer
An event in an interface cannot have an initializer. For more information, see Interfaces.
The following sample generates CS0068:
// CS0068.cs
delegate void MyDelegate();
interface I
{
event MyDelegate d = new MyDelegate(M.f); // CS0068
// try the following line instead
// event MyDelegate d2;
}
class M
{
event MyDelegate d = new MyDelegate(M.f);
public static void f()
{
}
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: