#region继承接口的准则?

时间:2013-05-28 07:07:53

标签: c#

考虑这些界面:

interface IBar
{
    void bar();
}

interface IFoo : IBar
{
    void foo();
}

通常使用#region块对代码进行分组。在实现IFoo的具体类中,我可以想到两个有意义的区域配置。

我的问题是;哪一个是首选惯例?请激励你的答案。

A:

class Foo : IFoo
{
    #region IFoo interface
    void foo() {}
    void bar() {}
    #endregion
}

B:

class Foo : IFoo
{
    #region IFoo interface
    void foo() {}
    #endregion

    #region IBar interface
    void bar() {}
    #endregion
}

2 个答案:

答案 0 :(得分:3)

如果区域划分不同的逻辑区域,那么B是首选(并且是我个人的偏好)。

答案 1 :(得分:1)

让团队中的所有开发人员对最易阅读的风格进行投票,然后坚持下去。