dynamically create an array of primitive type

G

Guest

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?
 
G

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top