-
-
Save christiannagel/4cee893919a31e6451208d5aae73bc88 to your computer and use it in GitHub Desktop.
Range struct needed by C# 8 range features
This file contains 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 readonly struct Range | |
{ | |
public Index Start { get; } | |
public Index End { get; } | |
private Range(Index start, Index end) | |
=> (Start, End) = (start, end); | |
public static Range Create(Index start, Index end) => new Range(start, end); | |
public static Range FromStart(Index start) => new Range(start, new Index(0, fromEnd: true)); | |
public static Range ToEnd(Index end) => new Range(new Index(0, fromEnd: false), end); | |
public static Range All() => new Range(new Index(0, fromEnd: false), new Index(0, fromEnd: true)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment