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 3359820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:55:09+00:00 2026-05-18T02:55:09+00:00

I have 2 classes that inherit from a common base class. Each of these

  • 0

I have 2 classes that inherit from a common base class.

Each of these specialized classes load some data from a data base, process it and then save that information in text files.

The first class represents the information as a XML document.
The second class will store its information as a text file with delimiters separating fields.

What I want to do is to write a single Save method in the base class that can be used by both classes. As all classes will write to text files I was thinking in use a common representation to store their data in memory – for instance the first class will transform the XmlDocument to that common representation.

What is the best way to store this in memory, string, Stream?

Thanks

  • 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-18T02:55:09+00:00Added an answer on May 18, 2026 at 2:55 am

    If the derived classes represent the data very differently, don’t implement a common Save method for them, Those classes knows best how to Save their data.
    Make Save() abstract and have each of the subclass implement the saving.

    There might be something in common for doing a Save() (e.g. opening the actual file, error handling). So have your base class provide a Save() method that’s responsible for that which in turn calls a virtual Save(System.IO.TextWriter writer); method that each of your subclasses implement.

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

Sidebar

Related Questions

I have multiple classes that all derive from a base class, now some of
I have a collection of classes that inherit from an abstract class I created.
I have classes that store data, and methods to go get data for individual
I have two classes that each need an instance of each other to function.
I have some classes that will do something based on some conditions . The
Let's say I have an abstract base class that looks like this: class StellarObject(BaseModel):
Consider the following problem: You have a class 'A' that serves as a base
If I have interface IFoo, and have several classes that implement it, what is
What I'm talking about here are nested classes. Essentially, I have two classes that
For classes that have a long list of setters that are used frequently, I

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.