Microsoft.CodeAnalysis.Sarif.Extensions.ArrayMatches C# (CSharp) Method

ArrayMatches() static private method

Returns whether or not the range [startIndex, startIndex + target.Length) is equal to the supplied string.
static private ArrayMatches ( char array, int startIndex, string target ) : bool
array char The array to check.
startIndex int The start index in the array to check.
target string Target string to look for in the array.
return bool
        internal static bool ArrayMatches(char[] array, int startIndex, string target)
        {
            if (startIndex < 0)
            {
                return false;
            }

            int targetLength = target.Length;
            if (targetLength + startIndex >= array.Length)
            {
                return false;
            }

            for (int idx = 0; idx < targetLength; ++idx)
            {
                if (array[idx + startIndex] != target[idx])
                {
                    return false;
                }
            }

            return true;
        }

Usage Example

 public void Extensions_ArrayMatches_Mismatch()
 {
     Assert.IsFalse(Extensions.ArrayMatches(s_testArray, 0, "match"));
 }
All Usage Examples Of Microsoft.CodeAnalysis.Sarif.Extensions::ArrayMatches