Skip to content

Instantly share code, notes, and snippets.

@EdMSL
Created May 21, 2024 08:47
Show Gist options
  • Select an option

  • Save EdMSL/a025e972c7fb944f0ad9ff7e90403cae to your computer and use it in GitHub Desktop.

Select an option

Save EdMSL/a025e972c7fb944f0ad9ff7e90403cae to your computer and use it in GitHub Desktop.
Замена для неэффективного метода сравнения строк String.EndsWith.
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