小编Vah*_*ahe的帖子

为什么可以从属性访问私有const字段?

这怎么可能?

namespace test
    {
        class Attr:Attribute
        {
            public Attr(int e)
            {
            }
        }

        [Attr(E)]
        class Test
        {
            private const int E = 0;
        }
    }
Run Code Online (Sandbox Code Playgroud)

它不违反封装原则吗?

c# oop attributes encapsulation private-members

6
推荐指数
1
解决办法
125
查看次数

标签 统计

attributes ×1

c# ×1

encapsulation ×1

oop ×1

private-members ×1