Is read-only auto-implemented property possible?

后端 未结 7 1605
你的背包
你的背包 2020-12-15 02:34

I found a topic on MSDN that talks that yes, this is possible.

I did a test that seems to break this statement:

using System;

namespace Test
{
    c         


        
7条回答
  •  Happy的楠姐
    2020-12-15 02:49

    It's confusing. You should differentiate read-only to the c# readonly (what the keyword means).

    • read-only: they mean that no one outside can write to it directly, only read.
    • C# readonly: you can only write to it in the constructor, then never more.

提交回复
热议问题