Switch / Dictionary containing multiple values with same keys I have different strings that will return different integers, though some strings have the same value (usually 4 per code).

I used a Dictionary first, and still have them, but it's kinda messy. I also tried using switch, which is basically the same to me in this case.

Here are two examples:

public static int PPCFloatCalc4RegistersSwitch(string code)
    {
        switch (code)
        {
            case "fsel": return 23;
            case "fsel.": return 23;
            case "fmul": return 25;
            case "fmul.": return 25;
            case "fm": return 25;
            case "fm.": return 25;
            case "fmuls": return 25;
            case "fmuls.": return 25;
            case "fms": return 28;
            case "fms.": return 28;
            case "fmsub": return 28;
            case "fmsub.": return 28;
            case "fmsubs": return 28;
            case "fmsubs.": return 28;
            case "fmadd": return 29;
            case "fmadd.": return 29;
            case "fma": return 29;
            case "fma.": return 29;
            case "fmadds": return 29;
            case "fmadds.": return 29;
            case "fnmsub": return 30;
            case "fnmsub.": return 30;
            case "fnmsubs": return 30;
            case "fnmsubs.": return 30;
            case "fnmadd": return 31;
            case "fnmadd.": return 31;
            case "fnmadds": return 31;
            case "fnmadds.": return 31;
        }

        return -1;
    }

    public static readonly Dictionary&lt;string, int&gt; PPCFloatCalc4RegistersDictionary = new Dictionary&lt;string, int&gt;
    {
        ["fsel"] = 23,
        ["fsel."] = 23,
        ["fmul"] = 25,
        ["fmul."] = 25,
        ["fm"] = 25,
        ["fm."] = 25,
        ["fmuls"] = 25,
        ["fmuls."] = 25,
        ["fms"] = 28,
        ["fms."] = 28,
        ["fmsub"] = 28,
        ["fmsub."] = 28,
        ["fmsubs"] = 28,
        ["fmsubs."] = 28,
        ["fmadd"] = 29,
        ["fmadd."] = 29,
        ["fma"] = 29,
        ["fma."] = 29,
        ["fmadds"] = 29,
        ["fmadds."] = 29,
        ["fnmsub"] = 30,
        ["fnmsub."] = 30,
        ["fnmsubs"] = 30,
        ["fnmsubs."] = 30,
        ["fnmadd"] = 31,
        ["fnmadd."] = 31,
        ["fnmadds"] = 31,
        ["fnmadds."] = 31,
    };


As you can see, it's repetitive, which is kinda bad for readability. It's worth noting that performance is a bit needed here, so switch/Dictionary speed would be great.

I don't think I need to add any more examples be cause the functions pretty much show what it does quite clearly.
Dictionary and switch are far from the same, even in your case.

As a general guideline I use a dictionary as a lookup mechanism and a switch as flow control. 

As a lookup mechanism a switch is less efficient than a dictionary. 

Maintenance wise, adding new values to a dictionary is not changing code per se. Modifying the dictionary will not cause a change to the code calling it. And a dictionary has a built in error check - you can't have the same key twice with different values.

However the switch is very much involved in program flow control. Therefore changing the switch code is higher risk than changing dictionary content.

Finally, using a dictionary decouples your data from the code that uses it. It makes the data re-usable. And you don't have duplicate switch code everywhere the data is used.