METHOD
MemoryExtensions.Overlaps
Tests whether views share any element storage, not whether their values are equal. When they overlap, the offset is the second span start relative to the first in elements; it can be negative.
Formal Syntax & Structure
csharp syntaxcsharp
span.Overlaps(other, out int elementOffset)Working Example
Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Buffers;using System.Buffers.Binary;using System.Runtime.CompilerServices;using System.Threading;int[] a={1,2,3}; Console.WriteLine(a.AsSpan().Overlaps(a.AsSpan(1),out int n)); Console.WriteLine(n); // True, 1