dataHeap = System.Array[System.Byte] is just remembering the array type, not creating the actual array instance. What I think you want is:
import System dataHeap = System.Array.CreateInstance(System.Byte, 4096) # creates a byte array 4k long if you want to then resize the array: dataHeap = Array.Resize[System.Byte](dataHeap, newSize) # resizes the array to the new size Both of those seem to work. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Haibo Luo Sent: Friday, January 12, 2007 8:50 AM To: Discussion of IronPython Subject: Re: [IronPython] Q: How to resize an System.Array ? dateHeap is a type in your code snippet below. The following code works, but I am not 100% sure it is expected to see the exception thrown for the last line. Dino? >>> import System >>> t = System.Array[System.Byte] >>> a = t([1,2]) >>> System.Array.Resize[System.Byte](a, 10) System.Byte[](1, 2, 0, 0, 0, 0, 0, 0, 0, 0) >>> System.Array.Resize(a, 10) Traceback (most recent call last): File , line 0, in <stdin>##27 TypeError: no callable targets, if this is a generic method make sure specify the type parameters -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bernd Viehmann Sent: Friday, January 12, 2007 3:47 AM To: [email protected] Subject: [IronPython] Q: How to resize an System.Array ? Hi, I have some problems with using >System.Array<-instances in ipy. I have found a way to create them, but not how to use the :-). Basically i want 2 use a MemoryStream in the following way ( kind of C#-way :-) ) : dataHeap = System.Array[System.Byte] dataHeap.Resize(dataHeap,4096) bytesRead = reader.Read(dataHeap, 0, PiceLength) But ipy does not understand me. I receive the message: dataHeap.Resize(dataHeap,4096) TypeError: no callable targets, if this is a generic method make sure specify the type parameters Any ideas who to use the mem-stream? Thanks much. Bernd _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
