Skip to content

Instantly share code, notes, and snippets.

@brunomikoski
Created October 22, 2013 11:07
Show Gist options
  • Save brunomikoski/7098760 to your computer and use it in GitHub Desktop.
Save brunomikoski/7098760 to your computer and use it in GitHub Desktop.
A simple way to circular navigation in arrays.
//Next
int i = (i+1) % targetArray.Count
//Prev
int i = (i + (targetArray.Count-1)) % targetArray.Count;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment