| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // System.Collections.Comparer
- //
- // Author:
- // Sergey Chaban ([email protected])
- //
- using System;
- using System.Collections;
- namespace System.Collections {
- public sealed class Comparer : IComparer {
- public static readonly Comparer Default;
- // Class constructor
- static Comparer ()
- {
- Default = new Comparer ();
- }
- // Public instance constructor
- private Comparer ()
- {
- }
- // IComparer
- public int Compare (object a, object b)
- {
- int res=0;
- if (a is IComparable) {
- res = (a as IComparable).CompareTo (b);
- } else if (b is IComparable) {
- res = (b as IComparable).CompareTo (a);
- } else {
- throw new ArgumentException ("Neither a nor b IComparable");
- }
- return res;
- }
- public override string ToString ()
- {
- return "mono::System.Collections.Comparer";
- }
- }
- }
|