I want to have the best performance and I know that array its faster than list but with array I need to create a variable for counter and even may need to use .Count
or .Length
to find the size so I though maybe better just use list? Below are the examples.
Example 1:
foreach (var item in items)
ItemCollection.Add(item);
Example 2:
int i = 0;
foreach (var item in items)
{
ItemCollection[i] = item;
i++;
}
Example 3:
for (int i = 0; i < items.Count; i++)
ItemCollection[i] = item;