123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using COSXML.CosException;
- using COSXML.Common;
- namespace COSXML.Utils
- {
- public sealed class StringUtils
- {
- public static int Compare(string strA, string strB, bool ignoreCase)
- {
- if (strA == null || strB == null)
- {
- throw new CosClientException((int)CosClientError.InvalidArgument, "strA = null or strA = null");
- }
- if (ignoreCase)
- {
- strA = strA.ToLower();
- strB = strB.ToLower();
- }
- int strALen = strA.Length;
- int strBLen = strB.Length;
- for (int i = 0, size = strALen > strBLen ? strBLen : strALen; i < size; i++)
- {
- int temp1 = (int)strA[i];
- int temp2 = (int)strB[i];
- if (temp1 > temp2)
- {
- return 1;
- }
- else
- if (temp1 < temp2)
- {
- return -1;
- }
- }
- if (strALen > strBLen)
- {
- return 1;
- }
- if (strALen < strBLen)
- {
- return -1;
- }
- return 0;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
|