Are you trying to create an array of GraphicsItem in a non-generic method?
You cannot do the following:
static void foo()
{
var _bar = List<GraphicsItem<T>>();
}
and then fill the list later.
More probably you are trying to do something like this?
static GraphicsItem<T>[] CreateArrays<T>()
{
GraphicsItem<T>[] _foo = new GraphicsItem<T>[1];
// This can't work, because you don't know if T == typeof(string)
// _foo[0] = (GraphicsItem<T>)new GraphicsItem<string>();
// You can only create an array of the scoped type parameter T
_foo[0] = new GraphicsItem<T>();
List<GraphicsItem<T>> _bar = new List<GraphicsItem<T>>();
// Again same reason as above
// _bar.Add(new GraphicsItem<string>());
// This works
_bar.Add(new GraphicsItem<T>());
return _bar.ToArray();
}
Remember you are going to need a generic type reference to create an array of a generic type. This can be either at method-level (using the T after the method) or at class-level (using the T after the class).
If you want the method to return an array of GraphicsItem and GraphicsItem, then let GraphicsItem inherit from a non-generic base class GraphicsItem and return an array of that. You will lose all type safety though.
Hope that helps.