Assume that I have a class library Lib that provides a class ClassA external service. ClassA has several read-only attributes, such as PropA and PropB. External callers cannot perform write operations on PropA and PropB in ClassA, so I can define this as follows: copy the code namespace Lib {public class ClassA {public string PropA {get; private set;} public string PropB {get; private set ;}}} copy the code, but the ClassB In the Lib library needs to write the PropA attribute in the ClassA. What should I do? If the set of open ClassA is public, the logic is broken. My approach is to define an interface IMemberSetter to write data to members. Copy the code namespace Lib {interface IMemberSetter {void SetMember (string member, object value) ;}} and then implement this interface in ClassA. Modify the Code as follows: copy the code namespace Lib {public class ClassA: IMemberSetter {private string propA; private string propB; public string PropA {get {return propA ;}} public string PropB {get {return propB;} void IMemberSetter. setMember (string member, object value) {switch (member) {case "Pr OpA ": this. propA = (string) value; break; case "PropB": this. propB = (string) value; break ;}}} copy the code. When ClassB wants to modify an attribute in ClassA, it only needs to convert ClassA to the IMemberSetter interface for access and then call the SetMember method. This idea is expected to be made by everyone, because if feasible, I will integrate it into the next project.