This is not a particularly common pattern, but it is a missed optimization all the same.
Consider:
publicstaticintArray_NE(byte[]src){intsum=0;for(inti=0;i!=src.Length;i++)sum+=src[i];returnsum;}publicstaticintArray_LT(byte[]src){intsum=0;for(inti=0;i<src.Length;i++)sum+=src[i];returnsum;}A bounds check is eliminated for the second method but not the first.
Applies to T[], string, Span<T>, ReadOnlySpan<T>, etc.
https://csharp.godbolt.org/z/bKzrE9Wjq
This is not a particularly common pattern, but it is a missed optimization all the same.
Consider:
A bounds check is eliminated for the second method but not the first.
Applies to
T[],string,Span<T>,ReadOnlySpan<T>, etc.https://csharp.godbolt.org/z/bKzrE9Wjq