AnsweredAssumed Answered

vrf What's up with Arrays?

Question asked by VRFuser on Nov 2, 2004
Ok, I got a problem. System.Array is an abstract class. So far so good.
There's a static method CreateInstance that creates an array of a given type
and size. Fine. Now, watch carefully. This works:

Set ary = Array.CreateInstance(System.Object, 0);

ary is an object of type System.Object[] with 0 elements (or actually maybe
one element - I can't figure that one out either). The problem is that this
doesn't work for intrinsic types:

Set ary = Array.CreateInstance(System.Int32, 0);

Fails with "'SET x=a' is not supported for 'a' not an Object, don't use
SET". Now, here's the problem. Ok you argue, a value type is different from
a reference type so that's why it doesn't work. Fine. Now how about this:

Set ary = Array.CreateInstance(Type.GetType("System.Int32"), 0);

This fails too! Why? GetType returns an object of type Type (a reference
type) that describes a value type. What's the story? It doesn't matter if
you try to increase the number of elements either. It simply doesn't work
and it ought to.

I think VEE is automatically converting Type to it's own intrinsic types as
soon as it sees them! This doesn't work either:

Set typ = asClrType(0, System.Int32);
Set ary = Array.CreateInstance(typ.GetType(), 0);

So the challenge is to create an empty array of any CLR intrinsic type.

You are currently subscribed to vrf as:
To subscribe send a blank email to "".
To unsubscribe send a blank email to "".
To send messages to this mailing list,  email "". 
If you need help with the mailing list send a message to "".