MBrendecke icon

String Contains

MBrendecke | PRO | 04/12/16 10:48:31 AM UTC | 0 ⭐ | 405 👁️ | Never ⏰ | []
C# |

360 B

|

None

|

0 👍

/

0 👎

public static bool Contains(this string soure, string match) {
    bool retVal = false;
    for (int sIndex = 0, mIndex = 0; (sIndex < source.Length || mIndex < match.Length) && source.Length >= match.Length - mIndex; sIndex++) {
        if (source[sIndex] == match[mIndex++] {
            retVal = true;
        } else {
            retVal = false;
            mIndex = 0;
        }
    }
    return retVal;
}

Comments