Is there a default ordered datastructure in .net that that supports custom comparison function?

StackOverflow https://stackoverflow.com/questions/23361181

  •  11-07-2023
  •  | 
  •  

문제

I want to sort objects according to values of their parameters which specify priority of processing.

HashSet and OrderedDictionary use IEqualityComparer only for checking equality.

도움이 되었습니까?

해결책

All the ordered containers from the BCL can accept a custom IComparer<T> that allows you to specify how their contents should be ordered (for example, SortedList<T>).

HashSet is an unordered container so it has no place in this discussion and SortedDictionary does accept an IComparer<TKey>.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top