System.Globalization.CompareInfo.CompareInfo.Compare C# (CSharp) Method

Compare() public method

public Compare ( string string1, int offset1, string string2, int offset2, CompareOptions options ) : int
string1 string
offset1 int
string2 string
offset2 int
options CompareOptions
return int
		public virtual int Compare (string string1, int offset1,
					    string string2, int offset2,
					    CompareOptions options)
		{
			if ((options & ValidCompareOptions) != options)
				throw new ArgumentException ("options");

			if (string1 == null) {
				if (string2 == null)
					return 0;
				return -1;
			}
			if (string2 == null)
				return 1;

			/* Not in the spec, but ms does these short
			 * cuts before checking the offsets (breaking
			 * the offset >= string length specified check
			 * in the process...)
			 */
			if((string1.Length == 0 || offset1 == string1.Length) &&
				(string2.Length == 0 || offset2 == string2.Length))
				return(0);

			if(offset1 < 0 || offset2 < 0) {
				throw new ArgumentOutOfRangeException ("Offsets must not be less than zero");
			}
			
			if(offset1 > string1.Length) {
				throw new ArgumentOutOfRangeException ("Offset1 is greater than or equal to the length of string1");
			}
			
			if(offset2 > string2.Length) {
				throw new ArgumentOutOfRangeException ("Offset2 is greater than or equal to the length of string2");
			}
			
			return(internal_compare_switch (string1, offset1,
						 string1.Length-offset1,
						 string2, offset2,
						 string2.Length-offset2,
						 options));
		}

Same methods

CompareInfo.CompareInfo::Compare ( string string1, int offset1, int length1, string string2, int offset2, int length2 ) : int
CompareInfo.CompareInfo::Compare ( string string1, int offset1, int length1, string string2, int offset2, int length2, CompareOptions options ) : int
CompareInfo.CompareInfo::Compare ( string string1, int offset1, string string2, int offset2 ) : int
CompareInfo.CompareInfo::Compare ( string string1, string string2 ) : int
CompareInfo.CompareInfo::Compare ( string string1, string string2, CompareOptions options ) : int