Collections Data Structure C#

using System;
using System.Collections.Generic;
using System.Collections;
  public static class CollectionUtils
  {
    public static T[] ToArray(this ICollection collection)
    {
      T[] res = new T[collection.Count];
      int i = 0;
      foreach (T elem in collection)
      {
        res[i] = elem;
        i++;
      }
      return res;
    }
  }