Custom Contains

mail@pastecode.io avatar
unknown
csharp
2 years ago
602 B
1
Indexable
Never
        public static bool CustomContains(this string value, string searchValue)
        {
            int valueCount = 0;
            for (int i = 0; i < value.Length; i++)
            {
                for (int j = valueCount; j < searchValue.Length; j++)
                {
                    if (value[i] == searchValue[j])
                        valueCount++;

                    if (valueCount == searchValue.Length)
                        return true;
                    else
                        break;
                }
            }
            return false;
        }