Dictionary<int, string>进行枚举遍历的时候,使用IEnumerable<KeyValuePair<TKey, TValue>>.当然完全可以用foreach遍历,foreach把枚举的复杂性降低了。
public static DictionarylistPartition; IEnumerable > partitiontemp = listPartition.Where(c => (!string.IsNullOrEmpty(province) ? c.Value.Trim().Contains(province) : true || !string.IsNullOrEmpty(ownCity) ? c.Value.Trim().Contains(ownCity) : true)); if (partitiontemp!=null) { partition = partitiontemp.First().Key; }[SerializableAttribute][ComVisibleAttribute(false)]public class Dictionary : IDictionary , ICollection >, IDictionary, ICollection, IReadOnlyDictionary , IReadOnlyCollection >, IEnumerable >, IEnumerable, ISerializable, IDeserializationCallback