Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

UniversalComparer(T) Class

  • Last UpdatedNov 18, 2025
  • 3 minute read
UniversalComparer(T) Class
A universal comparer that can be used to compare any two objects for equivalence using any combination of properties.

Inheritance Hierarchy

SystemObject
  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

  NameDescription
Public method
UniversalComparerT
Initializes a new instance of the UniversalComparerT class.

Methods

  NameDescription
Public methodCode example
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).)
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public method
GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
Initialize
Initialize the UniversalComparerT with a different sort order.
Public method
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.

Version Information

AFSDK


See Also

TitleResults for “How to create a CRG?”Also Available in