Game.SceneFlow.OverlayScreenComparer
Assembly:
Assembly-CSharp (game runtime assembly)
Namespace:
Game.SceneFlow
Type:
internal class
Base:
System.Collections.Generic.IComparer
Summary:
Compares two OverlayScreen values by their underlying integer values. This comparer casts each OverlayScreen enum value to int and uses int.CompareTo to determine ordering. Useful for sorting collections of OverlayScreen instances in ascending enum order.
Fields
- This type declares no instance or static fields.
Properties
- This type declares no properties.
Constructors
internal OverlayScreenComparer()
Compiler-generated default constructor. Instantiates the comparer for use where an ICompareris required.
Methods
public int Compare(OverlayScreen x, OverlayScreen y)
Compares two OverlayScreen values by casting them to int and returning the result of int.CompareTo. Because OverlayScreen is an enum (a value type), null handling is not required. The comparison result is:- less than zero if x has a smaller underlying value than y,
- zero if they are equal,
- greater than zero if x has a larger underlying value than y.
Implementation summary: - int num = (int)x; - return num.CompareTo((int)y);
Usage Example
// Sort a list of OverlayScreen values in ascending enum order
var list = new List<OverlayScreen> { OverlayScreen.Secondary, OverlayScreen.Primary, OverlayScreen.Tertiary };
list.Sort(new OverlayScreenComparer());
// Use with LINQ's OrderBy
var ordered = list.OrderBy(s => s, new OverlayScreenComparer()).ToList();