Home All Groups Group Topic Archive Search About

Reflection: Creating an array of a type?

Author
8 Mar 2006 3:31 PM
Axel Dahmen
Hi,

I'd like to create an array of a Type. How can I do that using reflection?

Currently I'm using the following code to create single instances:

  constr=type.GetConstructor(new Type[]{...});
  newObj=constr.Invoke(new object[]{...});

Now I need to create a typed array of that type to store a number of these
instances. How can I do that?

Any help is quite appreciated!

TIA,
Axel Dahmen

Author
8 Mar 2006 5:21 PM
Mattias Sjögren
Axel,

>Now I need to create a typed array of that type to store a number of these
>instances. How can I do that?

Array.CreateInstance


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
9 Mar 2006 10:47 AM
Axel Dahmen
Great! Thanks, Matthias!


--------------
Show quote
"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:uiV6YStQGHA.4312@TK2MSFTNGP12.phx.gbl...
> Axel,
>
> >Now I need to create a typed array of that type to store a number of
these
> >instances. How can I do that?
>
> Array.CreateInstance
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.

AddThis Social Bookmark Button