开发者

When might one use attribute targets?

开发者 https://www.devze.com 2023-03-14 14:39 出处:网络
When might one use attribute prefixes such as class:, return: and module: ? I haven\'t yet seen anyone use these prefixe开发者_Go百科s so I was wondering where they could be used.

When might one use attribute prefixes such as class:, return: and module: ?

I haven't yet seen anyone use these prefixe开发者_Go百科s so I was wondering where they could be used.

Example

namespace NameSpace {

    class Program {

        [return: Description("Returns true if is in a valid state")]
        [method: Description("Determines xyz")]
        public void IsValid) {
          return true;
        }
}


Here's a good article which explains where attribute targets could be useful and what problem they address. I remember using those back in the good old days before ASP.NET MVC was out and I was writing some MonoRail applications. The [return: JSONReturnBinder] allows to specify a binder for the return type of a controller action instead of input parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号