[Mono-dev] Arrays in a loop?
Martin Hinks
mhinks at gmail.com
Mon Oct 3 08:49:02 EDT 2005
Hi Eric,
First off, why are you enclosing the array name in curly braces?
MyArray[i, 0] should do the trick...
Secondly, how is your array defined? Have you checked that the
exception thrown isn't an "Out of range exception"? If it IS an
out-of-range exception you need to declare your array differently, if
not, post the declaration as well and i'll try to help more.
Thanks,
Martin Hinks
On 10/3/05, Eric Scott <scottishbug at cwazy.co.uk> wrote:
> I have a newbie C# question that I've been having difficulties
> finding an answer to. I have a global array, and am trying to assign
> data to it from as follows:
>
> int i = 0;
>
> foreach ( DataRow row in table.Rows )
> {
> {MyArray}[i, 0] = a;
> {MyArray}[i, 1] = x;
> {MyArray}[i, 2] = y;
> {MyArray}[i, 3] = z;
>
> i ++;
> }
>
> All the code executes properly once, but then stalls the second time
> it attempts to go through the loop. I've gathered there's something
> quarky about using arrays in a loop like this, but I haven't found any
> down-to-earth explanations that let me know how to fix my code.
> Thanx for any help you can offer,
> SigmaX
>
> --
> My home page: www.sigmax.cjb.net
>
> "Education is what remains after one has forgotten everything he learned in school"
> -Albert Einstein
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
--
Martin Hinks
http://www.m-s-d.net
More information about the Mono-devel-list
mailing list