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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:10:40+00:00 2026-05-29T09:10:40+00:00

In an old project we are using a third party assembly with a class

  • 0

In an old project we are using a third party assembly with a class that has a property with some hardcoded information:

public string ConnectionString
{
    get
    {
        string[] fullDbName = new string[5];
        fullDbName[0] = "Data Source=";
        fullDbName[1] = this.dbServer;
        fullDbName[2] = ";Initial Catalog=";
        fullDbName[3] = this.FullDbName;
        fullDbName[4] = ";Integrated Security=SSPI;Pooling=false";
        return string.Concat(fullDbName);
    }
}

I need to be able to construct the connection string my self. So I have tried to make a derived class that hides the original property, but it does not seem to work:

public class SqlServerRestorerExstension : SQLServerRestorer
{
    public SqlServerRestorerExstension(string dbServer, string dbName, string dbFilePath, string dbDataFileName, string dbLogFileName, bool detachOnFixtureTearDown, string connectionstring) : base(dbServer, dbName, dbFilePath, dbDataFileName, dbLogFileName, detachOnFixtureTearDown)
    {
        ConnectionString = connectionstring;
    }

    public string ConnectionString { get; private set; }
}

Is it possible do achive this in any way when I don’t have acces to the third party code?

  • 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-29T09:10:41+00:00Added an answer on May 29, 2026 at 9:10 am

    As others have pointed out you can use the new keyword to hide the base member property. Note however that this doesn’t magically turn the ConnectionString property into a polymorphic function, i.e. if you have something like this:

    public class A 
    {
        public string CString { get { return "a"; } }
    }
    
    public class B : A
    {
        public new string CString { get { return "b"; }}
    }
    

    and you do this:

    A a = new B();
    
    Console.WriteLine(a.CString);
    

    Then you will still see an “a” printed to the console. In fact the new keyword just stops the compiler from issuing a warning regarding the hiding of the member of the base class. It doesn’t change the behavior of the code at runtime.

    You can try to use a Decorator pattern and wrap the SQLServerRestorer, but if that doesn’t work either, you are out of luck I am afraid.

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

Sidebar

Related Questions

We have old .net 1.1 project that is using a third party component. Aparently
I'm using VS2008 for a C++ project. The code is quite old and has
i´m using ARC to update my old project. I have a Filehelper class in
I am currently re-implementing some project using Lift. All the old views were done
I have an old project that is using iTextSharp library for PDF generation. iTextSharp
We have an old project that is designed using VS2005 and WinForms. Everything works
i'm converting in PHP5 a quite old ASP project that was using a lot
I just converted an old project to ARC using Xcode's automatic refactoring. @property (nonatomic,
We have an old project written using Managed C++ syntax. I would like to
I'm trying to rebuild someone's old C++ project using Dev-C++ (version 4.9.9.2) and the

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.