结合在C#中的多个属性 [英] Combining multiple attributes in C#

查看:113
本文介绍了结合在C#中的多个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有以下的语法功能之间的区别...

Is there a functional difference between the following syntax...

[Foo, Bar]
public class Baz {}

...这语法?

...and this syntax?

[Foo]
[Bar]
public class Baz {}

假设编译时,每个产生相同的结果,这是preferred形式?

Assuming each produces identical results when compiled, which is the preferred form?

推荐答案

有没有功能上的差异。它的方便和风格的问题。

大多数情况下,我倾向于认为自己行的属性,以此来让他们分开,易于阅读。这也是不错的可以用行注释 // 单独删除属性。

Most often, I tend to see attributes on their own lines as a way to keep them separate and easy to read. It's also nice to be able to use the line comment // to remove attributes individually.

[A]
[B]
//[C] disabled
public class Foo {} 

这篇关于结合在C#中的多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆