AnsweredAssumed Answered

vrf What's up with Arrays?

Question asked by VRFuser on Nov 3, 2004

Try this:

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

> Set typ = asClrType(0, System.Int32);
The purpose of asClrType() is to provide a hint to VEE when marshalling
data from VEE to .NET.  In the case above, you get back a boxed
System.Int32 so it is a reference type but it is of type System.Int32
not System.Type.

BTW, I'm a little baffled as to why a "Set" is required on a constructor
call yet "Set" can't be used to assign the result of a static method
call.  Both return a reference type that would be assigned into a VEE
Object type.   Hmmm.


> -----Original Message-----
> From: Shawn Fessenden []
> Sent: Wednesday, November 03, 2004 1:27 AM
> To: VRF
> Subject: [vrf] What's up with Arrays?
> Ok, I got a problem. System.Array is an abstract class. So far so
> There's a static method CreateInstance that creates an array of a
> 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
> 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
> Set ary = Array.CreateInstance(Type.GetType("System.Int32"), 0);
> This fails too! Why? GetType returns an object of type Type (a
> type) that describes a value type. What's the story? It doesn't matter
> you try to increase the number of elements either. It simply doesn't
> and it ought to.
> I think VEE is automatically converting Type to it's own intrinsic
> 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

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 "".