Из кода ниже, как я могу получить dataHashSet, такой как «Volvo BEST», «BMW X100», «Ford Gs», «Mazda Rs». Спасибо.
string[] arrayData = {"Volvo BEST", "BMW X100", "Ford Gs", "Mazda Rs"};
HashSet<string> dataHashSet = new HashSet<string>();
int length;
string[] arrayCopy;
int maxItem = 500;
int remainingItem = arrayData.Length % maxItem;
int totalIteration = (remainingItem > 0 ? (arrayData.Length / maxItem) + 1 : (arrayData.Length / maxItem));
for (int i = 0; i < totalIteration; i++)
{
length = (i == (totalIteration - 1) && remainingItem != 0) ? remainingItem : maxItem;
arrayCopy = new string[length];
Array.Copy(arrayData, (i * maxItem), arrayCopy, 0, length);
dataHashSet.Add(String.Join(",", arrayCopy));
}
foreach(var item in dataHashSet)
{
Console.WriteLine(item);
}