Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 720037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:42:45+00:00 2026-05-14T05:42:45+00:00

I have three classes; Classes A and B both reference class C . How

  • 0

I have three classes; Classes A and B both reference class C.

How can I make it so members of class C can be modified when referenced from class A but not modified when referenced from class B?

IE, the following should be possible;

classA myClassA = new classA();
myClassA.myClassC.IssueNumber = 3;

But this should not be possible;

classB myClassB = new classB();
myClassB.myClassC.IssueNumber = 3;

Making classB.classC read-only still allows properties of classC to be altered.

I’m sure this is basic stuff but can’t find a simple answer.

Thanks,
A

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:42:46+00:00Added an answer on May 14, 2026 at 5:42 am

    Pattern 1: Make a simple read-only interface IRead. Make a simple write interface IWrite. Make an read-write interface IReadWrite : IRead, IWrite. Implement classC : IReadWrite. Declare myClassA.myClassC as IReadWrite. Declare myClassB.myClassC as IRead. (You don’t have to user IWrite anywhere if you don’t need it :-))

    Pattern 2: create a read-only wrapper for classC called ReadOnlyClassC and use that one in classB.

    Pattern 1 is used by the IO streams to split the reader and writer implementations and then combine them in read-write streams.

    Pattern 2 is used by the generic collections to provide read-only facet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C# I have three classes: Person, Cat, and Dog. Both the Cat and
I have the following classes defined: public interface Thingy { ... } public class
Using threads, I have a principal class ( SlaveCrawler ) that instantiates three classes(
Yes, I'm new to c#! :) i'm using .Net4 VS2010. I have Three classes
I have a problem with overriding the equals method in an Enum to make
Classes confuse me! For this particular assignment, we are to do the classic 'Cards
I have a webservice that I'm using JAX-WS annotations to generate the WSDL &
I am using the aQute Bnd toolset to create an OSGi bundle and have
I am trying to make a case to my bosses on why we should
I wonder what fits better into the CSS philosophy: CSS classes mark entities -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.