What is internal set property in c#?

前端 未结 8 733
悲&欢浪女
悲&欢浪女 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条回答
  •  忘掉有多难
    2021-02-01 01:21

    it is mostly used with constructors like

    public class CustomerConfig
    {
         public string CustomerName { get; internal set; }
         public CustomerConfig(string customerName)
         {
            this.CustomerName = customerName;
         }
    }
    

    By this way, you can preset some parameters and make them readonly for other assemblies in your code.

提交回复
热议问题