Microsoft.Languages.Core.Text.TextRange.Intersection C# (CSharp) Method

Intersection() public static method

Calculates range that is an intersection of the supplied ranges.
public static Intersection ( ITextRange range1, ITextRange range2 ) : ITextRange
range1 ITextRange
range2 ITextRange
return ITextRange
        public static ITextRange Intersection(ITextRange range1, ITextRange range2) {
            int start = Math.Max(range1.Start, range2.Start);
            int end = Math.Min(range1.End, range2.End);

            return start <= end ? TextRange.FromBounds(start, end) : TextRange.EmptyRange;
        }

Same methods

TextRange::Intersection ( ITextRange range1, int rangeStart, int rangeLength ) : ITextRange