Skip to content

Instantly share code, notes, and snippets.

@scarletquasar
Created November 28, 2022 00:32
Show Gist options
  • Save scarletquasar/ba9c6110d2a63bff43eebe120deee644 to your computer and use it in GitHub Desktop.
Save scarletquasar/ba9c6110d2a63bff43eebe120deee644 to your computer and use it in GitHub Desktop.
create false 'enumerable' type
public class Listify
{
public int Start { get; }
public int End { get; }
public Listify(int start, int end)
{
Start = start;
End = end;
}
public int this[int index]
{
get {
var value = start + index;
if (value > end) throw new IndexOutOfRangeException();
return value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment