Let's say I have a simple class which contains a bunch of attributes or properties:
internal class ConnectionProperties { internal string Name = "Default Name"; internal bool Enabled = false; } And these are used within a class called Data:
internal class Data { private ConnectionProperties _connection; internal Data() { this._connection = new ConnectionProperties(); // Business logic to configure connection this._connection.Name = "My Connection"; this._connection.Enabled = true; _ } } How can I allow external access to the properties and values of _connection WITHOUT allowing them to be changed from anywhere apart from the class Data.
I know I could add a property such as
internal ConnectionName => _connection.Name; But that feels very messy and could be tough to maintain