Compare

比较两个值的大小,其中一个是否“大于,小于或等于”另一个值。

这个版本比较两个bool 值。

int Compare(
   const bool  x,         //第一个值
   const bool  y          //第二个值
   );

这个版本比较两个char值。

int Compare(
   const char  x,         //第一个值
   const char  y          //第二个值
   );

这个版本比较两个uchar值。

int Compare(
   const uchar  x,        //第一个值
   const uchar  y         //第二个值
   );

这个版本比较两个short值。

int Compare(
   const short  x,        //第一个值
   const short  y         //第二个值
   );

这个版本比较两个ushort值。

int Compare(
   const ushort  x,       //第一个值
   const ushort  y        //第二个值
   );

这个版本比较两个color 值。

int Compare(
   const color  x,        //第一个值
   const color  y         //第二个值
   );

这个版本比较两个int 值。

int Compare(
   const int  x,          // 第一个值
   const int  y           // 第二个值
   );

这个版本比较两个uint值。

int Compare(
   const uint  x,         //第一个值
   const uint  y          //第二个值
   );

这个版本比较两个datetime值。

int Compare(
   const datetime  x,     //第一个值
   const datetime  y      //第二个值
   );

这个版本比较两个long值。

int Compare(
   const long  x,         // 第一个值
   const long  y          //第二个值
   );

这个版本比较两个ulong值。

int Compare(
   const ulong  x,        //第一个值
   const ulong  y         //第二个值
   );

这个版本比较两个float值。

int Compare(
   const float  x,        //第一个值
   const float  y         //第二个值
   );

这个版本比较两个double值。

int Compare(
   const double  x,       //第一个值
   const double  y        //第二个值
   );

这个版本比较两个string值。

int Compare(
   const string  x,       //第一个值
   const string  y        // 第二个值
   );

这个版本比较两个其他类型的值。

template<typename T>
int Compare(
    x,                  // 第一个值
    y                   //第二个值
   );

参数

x

[in]  第一个值

y

[in]  第二个值

返回值

返回表示相比较的两个值比率的数字:

  • 如果结果小于0,x则小于y(x<y)
  • 如果结果等于0,x则等于y(x=y)
  • 如果结果大于0,x则大于y(x>y)

注意

如果T类型是实施 IComparable<T>接口的对象,那么这些对象将根据其比较方法进行比较。在所有其他情况下,都返回0 。