Example #1
0
        public static int Compare(StringSection a, StringSection b, bool ignoreCase, System.Globalization.CultureInfo culture, System.Globalization.CompareOptions options)
        {
            var result = string.Compare(a.baseString, a.start, b.baseString, b.start, Math.Min(a.length, b.length), culture, options);

            // If the two strings are different lengths, they are not equal. The longer string will be considered greater.
            if (result == 0 && a.length != b.length)
            {
                return(a.length > b.length ? 1 : -1);
            }
            return(result);
        }
Example #2
0
        public static int Compare(StringSection a, StringSection b, StringComparison comparisonType)
        {
            var result = string.Compare(a.baseString, a.start, b.baseString, b.start, Math.Min(a.length, b.length), comparisonType);

            // If the two strings are different lengths, they are not equal. The longer string will be considered greater.
            if (result == 0 && a.length != b.length)
            {
                return(a.length > b.length ? 1 : -1);
            }
            return(result);
        }
Example #3
0
 public void Split(int index, out StringSection left, out StringSection right)
 {
     left  = new StringSection(this, 0, index);
     right = new StringSection(this, index, length - index);
 }
Example #4
0
 public StringSection(StringSection str, int start, int len)
 {
     this.baseString = str.baseString;
     this.length     = len;
     this.start      = start + str.start;
 }
Example #5
0
 public bool Equals(StringSection s)
 {
     return(Compare(this, s, false) == 0);
 }