Juval Lowy's C# Coding Standards Questions

后端 未结 8 2100
无人共我
无人共我 2021-01-30 18:07

I enjoy and highly recommend Juval Lowy\'s - C# Coding Standard. Juval explicitly avoids rationale for each directive in order to keep the standard tight (see the preface). Howe

8条回答
  •  悲哀的现实
    2021-01-30 18:25

    1.26 is about pre-lambda delegate { } syntax.

    // #1 Empty parenthesis on parameterless-anonymous methods would be:
    delegate() { }
    // #2 ... anonymous method could have been used on any delegate, is:
    delegate { }
    

    Remember, the latter can be assigned to any delegate, regardless of its parameters. The delegate just ignores these using some compiler trickery.

    If you define a delegate taking no parameters, explicitly say so using #1. Don't "leave the parenthesis out because your delegate doesn't take any parameters anyway".

提交回复
热议问题