I have a list of integers:
List<Int32?> numbers = new List<Int32?> { 2, 1, 3, null, 6, 7 }
I need to get a List with the difference between two consecutive values, so the result would be:
{ null, -1, 2, null, null, 1 }
null
-1 = 1-2
2 = 3-1
null = null-3
null = 6-null
1 = 7-6
Can this be done using LINQ?