Logo

Programming-Idioms

History of Idiom 163 > diff from v19 to v20

Edit summary for version 20 by bigwavedave:
New Csharp implementation by user [bigwavedave]

Version 19

2019-09-27, 22:58:19

Version 20

2019-10-05, 00:45:14

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Imports
using System.Collections.Generic;
Code
for(int i = 0; i < list.Count; i += 2) {
  Console.WriteLine(string.Format("{0}, {1}", list[i], list[i + 1]));
}