private static int GetTask(String value) { int ret = -1; foreach (var it in GetTask()) { if (string.Compare(value, it.Value, true) == 0) { ret = (int)it.Key; break; } } if (ret == -1) { throw new ArgumentException(); } return ret; }