Proper naming convention for a .NET Delegate type?

2019-01-20 23:38发布

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 a good way to differentiate its name when delegates are listed among types and other things?

My immediate assumption is to name a delegate more likely an adjective because a single method interface can often be replaced with a delegate.

Some thoughts:

delegate object ValueExtracting(object container);

delegate object ValueExtractor(object container);

delegate object ValueExtractionHandling(object container);

delegate object ValueExtractionHandler(object container);

7条回答
疯言疯语
2楼-- · 2019-01-21 00:28

Based on Enumerable.Sum, I'd pass the delegate as a Func<object, object> and name the parameter selector:

void Foo(Func<object, object> selector) ...

If you have to make your own delegate for it, I'd go with ValueExtractor since that's the most descriptive name for what it does.

查看更多
登录 后发表回答