Private 'set' in C# - having trouble wrapping my brain around it

前端 未结 9 2398
傲寒
傲寒 2021-02-12 10:34

I\'ve seen a lot of example code written using something like (please forgive how horribly canned this is):

public class Test
{
   public object Thingy { get; pr         


        
9条回答
  •  别那么骄傲
    2021-02-12 11:10

    The private makes it into a readonly property. A common example is if you have multiple classes passing around a single object, you don't want another class to be able to modify the instance.

提交回复
热议问题