C# object initialization of read only collection properties

后端 未结 4 1619
南笙
南笙 2020-11-27 21:11

For the life of me, I cannot figure out what is going on in the example piece of C# code below. The collection (List) property of the test class is set as read only, but ye

4条回答
  •  孤街浪徒
    2020-11-27 21:49

    I think that, beeing read only, you can't do

    c.StringCollection = new List();
    

    But you can assign items to list...
    Am I wrong?

提交回复
热议问题