static void Main(String[] args) { var strings = new String[] { "Pompey", null, "Claudius", null, "Caligula", null, null }; var compactedStrings = strings.Compact(); PrintWithNulls(strings); PrintWithNulls(compactedStrings); var numbers = new Int32[] { 0, 1, 2 }; var numbersCompacted = numbers.Compact(); PrintWithNulls(numbers); PrintWithNulls(numbersCompacted); }