Given class A, which contains sets of raw data, and class B, which contains a re-organized version (GUI ready) of that data I would like to make the raw data in A visible in B.
Clearly the raw data in class A is contained in private members. I would like to make that data visible in B though the use of something akin to the C++ friend classes method.
How can I approach this?
Thank you.
Strictly speaking, you can't define a specific class (or list of classes) that you can expose the data to. You can, however, use the internal
access modifier instead of private
, which makes the members available to any class in the same assembly.
That being said, you should strongly consider exposing these members through properties rather than fields (which is what I'm guessing you're planning on exposing). Doing this will allow the class to define exactly how that information can be exposed to other classes and what--if anything--should happen when another class changes the data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With