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

  • Home
  • SEARCH
  • 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 6703829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:13:04+00:00 2026-05-26T07:13:04+00:00

I have a class A that is inherited from B. A as some readonly

  • 0
  • I have a class A that is inherited from B.
    • A as some readonly properties that I want to modify from B
    • Hiding those properties with new is not a suitable option, cause the base class has some functions that use its own properties…
    • Can’t use the override keyword, cause the properties are not marked as abstract, virtual nor override

So I’d like to know whether from the inherited class (B) I can totally recreate the actual instance of my object to access those readonly properties.

For example and for a better explaination, for a class inheriting Tuple, if it was possible, I would do something like this:

    public new T3 Item3
    {
        get { return item3; }
        set 
        {
            item3 = value;
            base = new Tuple<T1, T2, T3>(Item1, Item2, Item3); // Not valid
        }
    }

I can’t see how to do this?

  • 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-26T07:13:05+00:00Added an answer on May 26, 2026 at 7:13 am

    A tuple is immutable, so you can’t change its values. When you have immutable objects, the way to change them is to return a new object with the desired properties changed. So if you want to stick with tuples, you could do something like this:

    public static class TupleExtensions {
      public static Tuple<T1, T2, T3> 
        WhereItem3Is<T1, T2, T3>(this Tuple<T1, T2, T3> self, T3 newValue) {
        return Tuple.Create(self.Item1, self.Item2, newValue);
      }
      // other methods for Tuple<,,> or other Tuples...
    }
    

    And use it like this:

    var t = Tuple.Create(1, 2, 3);
    // ...
    t = t.WhereItem3Is(4);
    

    But it’s a little bit painful to write all those methods. So if you need many of them, better just do this:

    var t = Tuple.Create(1, 2, 3);
    t = Tuple.Create(t1.Item1, t1.Item2, 4);
    

    You could even have a wrapper type that you’d use to reference the tuple from different places in your code, so that any “changes” could be visible:

    var t = Tuple.Create(1, 2, 3);
    var r = new Ref<Tuple<int, int, int>>(t);
    // share r ...
    r.Value = Tuple.Create(r.Value.Item1, r.Value.Item2, 4);
    
    ...
    
    public class Ref<T> {
      public T Value { get; set; }
      public Ref(T value) { Value = value; } 
    }
    

    All this, though, feels very awkward. Maybe you could better explain the essential problem you’re having so that better answers could be provided. Maybe you don’t really need a tuple after all, just something more specific to your domain.

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

Sidebar

Related Questions

I have a class that is inherited from List<T> and also has some properties,
I used to have a class in 1.1 for the Datagrid that inherited from
I have a class that is inherited from an abstract base class. class CStateBase
In C#, I have a class A that I cannot modify. From this class
Sometimes you have a class that is designed to be inherited, but not all
I have a class that inherits from ObservableCollection(Of MyObject) and the MyObject class handles
I have a class that inherits from a base class (this contains a lot
I have a class that inherits from a generic dictionary as follows: Class myClass
I have a class that inherits from Page, called APage. public abstract class APage:
Example: I have an class that inherits from UIImageView. An object creates an instance

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.