FindMismatchPosition() static public method

Shows the position two strings start to differ. Comparison starts at the start index.
static public FindMismatchPosition ( string expected, string actual, int istart, bool ignoreCase ) : int
expected string The expected string
actual string The actual string
istart int The index in the strings at which comparison should start
ignoreCase bool Boolean indicating whether case should be ignored
return int
示例#1
0
        private void DisplayStringDifferences(MessageWriter writer, string expected, string actual)
        {
            int num = MsgUtils.FindMismatchPosition(expected, actual, 0, comparer.IgnoreCase);

            if (expected.Length == actual.Length)
            {
                writer.WriteMessageLine(StringsDiffer_1, expected.Length, num);
            }
            else
            {
                writer.WriteMessageLine(StringsDiffer_2, expected.Length, actual.Length, num);
            }
            writer.DisplayStringDifferences(expected, actual, num, comparer.IgnoreCase, clipStrings);
        }
示例#2
0
        private void DisplayStringDifferences(MessageWriter writer, string expected, string actual)
        {
            int mismatch = MsgUtils.FindMismatchPosition(expected, actual, 0, caseInsensitive);

            if (expected.Length == actual.Length)
            {
                writer.WriteMessageLine(StringsDiffer_1, expected.Length, mismatch);
            }
            else
            {
                writer.WriteMessageLine(StringsDiffer_2, expected.Length, actual.Length, mismatch);
            }

            writer.DisplayStringDifferences(expected, actual, mismatch, caseInsensitive, clipStrings);
        }