Property backing value scope

前端 未结 6 1327
情书的邮戳
情书的邮戳 2021-02-12 19:10

Is anything like this possible? I\'m assuming not, but it looks good to me:

class MyClass {
    public int Foo {
        get { return m_foo; }
        s         


        
6条回答
  •  眼角桃花
    2021-02-12 19:50

    According to the C# 4.0 language specifications.

    However, unlike fields, properties do not denote storage locations. Instead, properties have accessors that specify the statements to be executed when their values are read or written.

    Adding a field would require a memory location. So no, this is not possible.

提交回复
热议问题