I tried to make the steps as explicit as possible and not use too much special features of C# (for example in a real program you should tend to use a proper class of its own for complex keys instead of an simple Tuple), so the above snippet should be easily portable to Java and other languages.