是否有约定,在C#修饰符的顺序? [英] Is there a convention to the order of modifiers in C#?

查看:178
本文介绍了是否有约定,在C#修饰符的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我是使用一个以上的,我应该用什么样的顺序修饰符关键字,如:

If I were to use more than one, what order should I use modifier keywords such as:

公共私人保护虚拟摘要覆盖静态内部密封,任何人,我忘了。

public, private, protected, virtual, abstract, override, new, static, internal, sealed, and any others I'm forgetting.

推荐答案

如果您下载Microsoft 了StyleCop Visual Studio的插件,它可以验证你的源$ C ​​$ C反对微软的一些团队使用的规则。它喜欢访问修饰符来第一位。

If you download the Microsoft StyleCop Visual Studio addin, it can validate your source code against the rules some teams in Microsoft use. It likes the access modifier to come first.

编辑:微软本身并不完全一致;不同的团队使用不同的样式。例如。了StyleCop建议使用的命名空间指令推杆;但这不是遵循的罗斯林源$ C ​​$ C。

Microsoft isn't itself totally consistent; different teams use different styles. Eg. StyleCop suggests putting using directives in the namespace; but this is not followed in the Roslyn source code.

这篇关于是否有约定,在C#修饰符的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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