Dictionary refactoring, key type change

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

I have already added the GetKey () method to my interface.

Edit: The library is used in other DLLs, and I want to limit the possible changes to only one library. This is a nimble store, so we must be prepared for change.

+3
source share
2 answers

, , .

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

Equals() GetHashCode() .

, , , Resharper - , .

+4

, :

    • int
    • / int ( )
    • GetHashCode() Equal(),
  • keyType
  • ,
  • keyType, , keyType
+1

All Articles