The way you'll want to make an array is:

import System

System.Array.CreateInstance(System.Char, 3)

Where 3 is the number of elements in the array.  

In the first case we're auto-marshalling your list into a byte[] array but we 
auto-marshal in a zero-length byte array (because you gave us a zero-length 
list).  Note that we won't back-propagate any changes to your list here so this 
is only effective for incoming parameters.

The 2nd case won't work because we can't convert the list to a byte.  

In Beta 3 we've also looked into improving array semantics in general.  It 
looks like we'll have an additional form of syntax for creating arrays that are 
initialized w/ values.  That tentatively looks like:

System.Array[int](2,3,4,5)

Where here we'd create an array of int's w/ 4 elements containing the values 
2,3,4,5.  But Array.CreateInstance remains the preferred syntax for creating 
arrays w/ no initial values.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paparipote .
Sent: Saturday, February 11, 2006 8:28 AM
To: [email protected]
Subject: [IronPython] Using StreamReader.Read(char[], Int32, Int32)

Hello:
I need your guidelines please, I am a little (or very??) confused with the 
next:
.
.
.
r = StreamReader(file,System.Text.Encoding.Default)
c=[] ??
r.Read(c,0,3)
Traceback (most recent call last):
  File , line 0, in input##43
  File mscorlib, line unknown, in Read
ValueError: Offset and length were out of bounds for the array or count is 
greaer than the number of elements from index to the end of the source 
collection.

if I write:
c=[[],[],[]]
r.Read(c,0,3)
Traceback (most recent call last):
  File , line 0, in input##48
TypeError: bad args to this method <method# Read on System.IO.StreamReader>

Well ... the question is: how can I define an array of chars so I can avoid 
this message?

Thanks.

_________________________________________________________________
MSN Amor: busca tu ½ naranja http://latam.msn.com/amor/

_______________________________________________
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

Reply via email to