I need to iterate and count. What is fastest or preferred: ToArray() or ToList()?

Viewed 11747

Possible Duplicate:
Is it better to call ToList() or ToArray() in LINQ queries?

I have code like this:

void Foobar(string[] arr, Dictionary<string, string[]>)
{
   var t = arr.Intersect(dic.Keys).ToList(); // .or ToArray() ?
   foreach(var item in t)
   {
      ..
   }

   var j = t.Count; // also I need this
}

which method is preferred?

I could go without any but I need to know the size and I don't want to call Enumerable.Count<T>() - it seems do do more actions then Array<T>.Size or List<T>.Count. Am I right?

3 Answers
Related