Created
May 21, 2024 08:47
-
-
Save EdMSL/a025e972c7fb944f0ad9ff7e90403cae to your computer and use it in GitHub Desktop.
Замена для неэффективного метода сравнения строк String.EndsWith.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static bool CustomEndsWith(this string a, string b) | |
| { | |
| int ap = a.Length - 1; | |
| int bp = b.Length - 1; | |
| while (ap >= 0 && bp >= 0 && a [ap] == b [bp]) | |
| { | |
| ap--; | |
| bp--; | |
| } | |
| return (bp < 0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment