© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
14 replies
Gipper

❔ How to share private variable data between classes when can't inherit?

If I'm supposed to try to encapsulate data as much as possible how can I share data without making everything public if I can't inherit? I'm working on a WPF project right now, but I think this is a problem that would come up in any other time when I can't inherit the data I need (mostly in my experience because I would have to inherit from more than one base class, although maybe there are other times). I keep reading that I should do interfaces to share stuff when I can't inherit, but afaik interfaces only share behavior...not data itself...I can imagine there are ways to share data indirectly through shared behavior but I don't know if I should do it that way or how to do that...
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

data transfer between classes
C#CC# / help
4y ago
Can't assign private variable (Unity)
C#CC# / help
14mo ago
How to share instance of an object in base class to its inherited classes?
C#CC# / help
3y ago
❔ basic c# how to inherits toolkit ObservableRecipient when you are already inherit something else ?
C#CC# / help
3y ago