Proper naming convention for a .NET Delegate type?

后端 未结 8 1999
我寻月下人不归
我寻月下人不归 2020-12-12 11:29

By convention classes are often named like nouns, methods like verbs and interfaces like adjectives.

What is the common naming convention for a delegate? Or what\'s

8条回答
  •  死守一世寂寞
    2020-12-12 12:05

    I never thought about it, mostly because I just use one of the EventHandler, Func, or Action overloads and never bother defining my own. I would probably pick ValueExtractor from those you've listed. This makes it sound more like an object, and when you invoke it you'll be using that object to perform an action. For example:

    ValueExtractor extractor += Blah;
    var value = extractor(data);
    

    Additionally, most of the built-in delegates are named like nouns as well. When in doubt, follow the .NET framework.

提交回复
热议问题