UniversalComparer(T) Class
- Last UpdatedNov 18, 2025
- 3 minute read
- PI System
- AF SDK 2024 R2
- Developer
Inheritance Hierarchy
System.Collections.GenericComparerT
OSIsoft.AFUniversalComparerT
Namespace: OSIsoft.AF
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public sealed class UniversalComparer<T> : Comparer<T>
Public NotInheritable Class UniversalComparer(Of T) Inherits Comparer(Of T) Dim instance As UniversalComparer(Of T)
generic<typename T> public ref class UniversalComparer sealed : public Comparer<T>
[<SealedAttribute>] type UniversalComparer<'T> = class inherit Comparer<'T> end
Type Parameters
- T
- The type of objects to compare.
The UniversalComparerT type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| UniversalComparerT |
Initializes a new instance of the UniversalComparerT class.
|
Methods
| Name | Description | |
|---|---|---|
| Compare |
Performs a comparison of two objects of the type and sort criteria
specified in the constructor and returns a value indicating whether
one is less than, equal to, or greater than the other.
(Overrides ComparerTCompare(T, T).) | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| Initialize |
Initialize the UniversalComparerT with a different sort order.
| |
| ToString | Returns a string that represents the current object. (Inherited from Object.) |
Remarks
The universal comparer can compare two objects of any type and any combination of properties. It also supports sorting in both ascending and descending order.
This comparer relies heavily on reflection and the generation of dynamic methods. A dynamic method is a method that is created in-memory during runtime to create a strongly typed version of the Compare(T, T) method. This provides a very powerful way of getting a strongly typed method while keeping it completely dynamic and very fast. The performance is very close to a specific hard-coded comparer.