What is a good substitute for a big switch-case?

You can store country-power pairs into a Dictionary<string, int> then just get the score of a particular country by using indexer:

var points = new Dictionary<string,int>();
// populate the dictionary...
var usa = points["USA"];

Edit: As suggested in comments you should store the information in external file, for example an xml would be a good choice. That way you don’t have to modify the code to add or remove countries. You just need to store them into XML file, edit it whenever you need.Then parse it when your program starts, and load the values into Dictionary.You can use LINQ to XML for that.If you haven’t use it before there are good examples in the documentation to get you started.

Leave a Comment