List dansConList = new List();
dansConList[0] = 1;
dansConList[1] = 2;
dansConList[2] = 3;
List dansRandomList = new List
You can use this extension method:
public static bool IsConsecutive(this IEnumerable ints )
{
//if (!ints.Any())
// return true; //Is empty consecutive?
// I think I prefer exception for empty list but I guess it depends
int start = ints.First();
return !ints.Where((x, i) => x != i+start).Any();
}
Use it like this:
[Test]
public void ConsecutiveTest()
{
var ints = new List {1, 2, 4};
bool isConsecutive = ints.IsConsecutive();
}