public void Export() { _CSVExporter.ClearReport(); _CSVExporter.SetTeams(_teamManager.Teams[0].TeamName, _teamManager.Teams[1].TeamName); int team1RecordsCount = 0; foreach (var key in _team1Timestamps.Keys) { team1RecordsCount += _team1Timestamps[key].Count; } int team2RecordsCount = 0; foreach (var key in _team2Timestamps.Keys) { team2RecordsCount += _team2Timestamps[key].Count; } var maxTeamRecords = team1RecordsCount > team2RecordsCount ? _team1Timestamps : _team2Timestamps; foreach (var key in maxTeamRecords.Keys) { for (int i = 0; i < maxTeamRecords[key].Count; i++) { string[] stringToAppend = new string[4]; if (_team1Timestamps.ContainsKey(key) && i < _team1Timestamps[key].Count) { stringToAppend[0] = key.ToString(); stringToAppend[1] = _team1Timestamps[key][i]; } else { stringToAppend[0] = string.Empty; stringToAppend[1] = string.Empty; } if (_team2Timestamps.ContainsKey(key) && i < _team2Timestamps[key].Count) { stringToAppend[2] = key.ToString(); stringToAppend[3] = _team2Timestamps[key][i]; } else { stringToAppend[2] = string.Empty; stringToAppend[3] = string.Empty; } _CSVExporter.AppendToReport(stringToAppend); } } }