What is internal set property in c#?

前端 未结 8 645
悲&欢浪女
悲&欢浪女 2021-02-01 01:01

I just came across an unknown concept of c# for me. Can anyone tell me what the purpose of an internal set property is? What is its use? I know internal keyword is used for work

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 01:21

    given a property declared public string MyString {get; internal set;} this means that

    • you can read the property's value from anywhere withhin your application (public string MyString)
    • but you may only write a new value to the property from inside the assembly in which it is declared - or from friend assemblies. (internal set;)

提交回复
热议问题