Created
July 21, 2011 09:55
-
-
Save N-Carter/1096890 to your computer and use it in GitHub Desktop.
Generic List extension method
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
namespace Testbed | |
{ | |
static class Extensions | |
{ | |
public static T ElementFromWrappedIndex<T>(this List<T> list, int i) | |
{ | |
return list[i]; | |
} | |
} | |
class MainClass | |
{ | |
public static void Main(string[] args) | |
{ | |
var list = new List<int>() {1, 2, 4, 8, 16, 32}; | |
for(int i = 0; i < list.Count; ++i) | |
Console.WriteLine("{0}: {1}", i, list.ElementFromWrappedIndex(i)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment