Solutions
The following sections describe solutions to the preceding problems. You can download the example solutions, to see additional details and to experiment with the programs at https://github.com/PacktPublishing/The-Modern-CSharp-Challenge/tree/master/Chapter05.
56. Roman numerals
There are many ways that you could approach this problem. I decided to use lookup tables to make things faster and simpler.
The following code shows a string extension method that converts a Roman numeral string into a long integer:
// Maps letters to numbers. private static Dictionary<char, long> LetterValues = null; // Convert Roman numerals into an integer. public static long ToArabic(this string roman) { // Initialize the letter lookup table if // it hasn't been initialized yet. if (LetterValues == null) { LetterValues = new Dictionary<char, long>(); LetterValues.Add('I', 1); LetterValues.Add('V', 5); LetterValues.Add('X', 10); LetterValues...