C
C#2y ago
MidDev

❔ Encapsulation with Extension Method

Question: I have some extension methods for a class, those extension methods set the properties of that class with some validation logic inside the problem is that when i wanna use the extension method it also shows the property as an option, i was wondering if there is a way to only show the extension methods as a valid option to set those properties up.
2 Replies
HimmDawg
HimmDawg2y ago
Depends. If you are in control of the class, then just make the property private set;. In any other case I guess you'll have to go with a proxy class that only exposes the methods and properties you want it to expose.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server