Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does declaring a delegate as static cause compiler error "The modifier 'static' is not valid for this item"?

This gives me a compiler error:

public static delegate void SomeCoolDelegate();

Why?

like image 239
richard Avatar asked Dec 05 '25 16:12

richard


1 Answers

That has no meaning for a delegate; I mean, semantically, it's like saying I never want an implementation of this method signature!

You could declare an implementation as static...

 protected static SomeCoolDelegate SomeMethod { get; set; }

When you mark a class as static, you're saying you never want it instantiated. A delegate is simply a way of identifying a method signature.

like image 170
Tejs Avatar answered Dec 08 '25 08:12

Tejs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!