© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
42 replies
futurized

trying to learn encapsulation

Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties’ direct access to them. Publicly accessible methods are generally provided in the class (so-called getters and setters) to access the values, and other client classes call these methods to retrieve and modify the values within the object.

I'm not really understanding this as why can't an unauthorised party just, for example, write obj1.GetAge()? How would encapsulation prevent access?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Trying to learn more
C#CC# / help
7mo ago
Trying to learn EF Core
C#CC# / help
16mo ago
❔ Trying to learn visual scripting.
C#CC# / help
3y ago
Trying to learn about interfaces
C#CC# / help
3y ago