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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:49:52+00:00 2026-05-22T21:49:52+00:00

I am refactoring a C# library that uses a Dictionary<int, SomeInterface> all over the

  • 0

I am refactoring a C# library that uses a Dictionary<int, SomeInterface> all over the system.
I need to change the key type from int to string, and use a Dictionary<string, SomeInterface> instead, and I am making dozens of changes.
How to do it better, how to define a type in one place and uses it everywhere, so that if I need to change it later, I can change it in one place?

I already added a GetKey() method to my interface.

Edit: the library is used in other DLLs, and I want to limit possible changes to only one library. This is an agile shop, so we need to be ready for changes.

  • 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-22T21:49:53+00:00Added an answer on May 22, 2026 at 9:49 pm

    If swapping the type of key is important to you, consider a custom class wrapping the underlying key.

    e.g, public class Key { public Key(object adaptee) { ... } }

    Remember to implement Equals() and GetHashCode() and just delegate to the underlying object.

    I’m not sure if this helps your particular scenario, but in general, Resharper is a fantastic tool to help assist with these types of changes.

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

Sidebar

Related Questions

While refactoring code and ridding myself of all those #defines that we're now taught
Whilst refactoring some old code I realised that a particular header file was full
Whilst refactoring some legacy C++ code I found that I could potentially remove some
Whilst refactoring some code I came across some getter methods that returns a std::string.
I'm refactoring some PHP code and discovered that certain nested combinations of if ()
I am working in a project that has two main parts: a class library
I'm in the process of making some changes to a library that I'm using.
I'm building a class library that will have some public & private methods. I
Rope is a refactoring library for Python and RopeVim is a Vim plugin which
While doing some refactoring, I renamed a variable from oldName to newName . Is

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.