Assignment to readonly property in initializer list

前端 未结 3 1241
生来不讨喜
生来不讨喜 2020-12-21 10:01

Can one tell me, why the heck does it compile?

namespace ManagedConsoleSketchbook
{
    public interface IMyInterface
    {
        int IntfProp
        {
           


        
3条回答
  •  心在旅途
    2020-12-21 10:35

    Because

    int IntfProp {
        get;
        set;
    }
    

    is not readonly.

    You did not invoke setter of MyClass.Property, just getter.

提交回复
热议问题