Home All Groups Group Topic Archive Search About

dynamically create an array of primitive type

Author
24 Jul 2006 2:38 PM
Roy
I have an Type object indicating a primitive data type I want such as
integer, short. How do I dynamically create an array of an primitive type by
using reflection?

Author
24 Jul 2006 3:09 PM
Giuseppe Lippolis
Hello Roy,

> I have an Type object indicating a primitive data type I want such as
> integer, short. How do I dynamically create an array of an primitive
> type by using reflection?
>

Type arrayType=typeof(int).MakeArrayType(5);
object objArray= Activator.CreateIstance(arrayType);

AddThis Social Bookmark Button