Skip to content

Instantly share code, notes, and snippets.

@nekman
Created August 16, 2013 13:43
Show Gist options
  • Save nekman/6250089 to your computer and use it in GitHub Desktop.
Save nekman/6250089 to your computer and use it in GitHub Desktop.
class Example
{
const int VAGVAL1 = 1;
const int VAGVAL2 = 2;
const int VAGVAL3 = 3;
readonly IDictionary<int, Action> _lookupMap;
public Example() {
_lookupMap = new Dictionary<int, Action>() {
{ VAGVAL1, Action1 },
{ VAGVAL2, Action2 },
{ VAGVAL3, Action3 }
};
}
public void Metod(int vagvalsparameter) {
Action result = null;
_lookupMap.TryGetValue(vagvalsparameter, out result);
if (result != null) {
result();
}
}
private void Action1() {
// do action 1
}
private void Action2() {
// do action 2
}
private void Action3() {
// do action 3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment