Skip to main content

Delegate cannot be marked static

In This Article

CodeRush Classic shows the Delegate cannot be marked static code issue if a delegate is marked static.

#Fix

Remove the static keyword from the delegate declaration.

#Purpose

Highlights the delegate declaration statements, which would cause the The modifier ‘static’ is not valid for this item compilation error.

#Example

public static delegate void MyDelegate(string str);

Fix:

public delegate void MyDelegate(string str);