CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
int[] x = new int[] {1, 2, 3, 4, 5, 6, 7, 8}; // <~~~ var retorno = db.retornoDb.Tolist()
int[] t = new int[] {500, 501, 502, 503}; // <~~~ int[] IdTecnico
int xn = t.Length;
Dictionary<int, List<int>> tecnicosDivididos = new Dictionary<int, List<int>>();
// inicializa os itens no dicionario
foreach(int T in t) {
tecnicosDivididos.Add(T, new List<int>());
}
for(int i = 0; i < x.Length; i++) {
int I = i % xn;
int name = t[I];
(tecnicosDivididos[name] as List<int>).Add(x[i]);
}
foreach(KeyValuePair<int, List<int>> item in tecnicosDivididos) {
Console.WriteLine("{0} => {1}", item.Key, string.Join(", ", item.Value));
}
}
}