I have a dictionary:
Dictionary<ICD_Map2, string> maps = new Dictionary<ICD_Map2, string>();
public class ICD_Map2
{
public string call_type {get; set; }
public string destination{get; set;}
}
maps.Add(new ICD_Map2() {call_type = "Mobile SMS", destination = "Australia"},"Local Text");
maps.Add(new ICD_Map2() {call_type = "Mobile SMS", destination = "International"},"International Text");
So what I want is, when I pass two variables:
Case 1 variable1 = "Mobile SMS" && variable2 = "Australia" I want a function to return "Local Text"
Case 2 "International Text" depending on my input variables matching ICD_Map2 definition "Mobile SMS" and "International".`
How do I construct this mapping function to return the First of the set from a set ofresults (if there are more than one)? This is a very simplified example, I have over 100 mappings.
To use a dictionary, the key needs to support equality operations. For example:
Note making it read-only is intentional: mutable keys are going to cause huge problems – avoid that.
Now you can use this as a key, for example:
The reverse lookup is problematic, and cannot be optimised unless you have a second dictionary. A simple operation (performance O(n)) would be:
Putting it all together: