I need to use a list pulled from sql, list is built from
Dictionary<Int32, String> measurementTypes = this.GetIndicatorTypes(MeasurementTypeFilter.All);
is ther a way to retrive the key using the string.
Something like
TypeID = measurementTypes.contains("GEN");
Well, it’ll be slow (i.e. O(n)), but you can do:
That will give you a sequence of pairs which have the given value. There could be 0, 1 or many matches. From there you can pick the first matching key etc – whatever you need. Using
FirstorSinglewould be appropriate if you think there will be at least one or exactly one;FirstOrDefaultwould return 0 if there were no matches, which may not be appropriate for you if 0 could also be a valid key.