Combining multiple attributes in C#

前端 未结 3 2034
旧巷少年郎
旧巷少年郎 2020-12-17 07:32

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

[Foo, Bar]
public class Baz {}

...and this syntax?

[Foo]
[         


        
3条回答
  •  执笔经年
    2020-12-17 08:14

    There is no functional difference. It's a question of convenience and style.

    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 {} 
    

提交回复
热议问题