Re: Technical two dimensional array question
- From: "Bjorn Abelli" <bjorn_abelli@xxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 2 Jan 2006 15:15:21 +0100
"Jesika" wrote...
> Given the following declaration:
>
> string [,] varray = new string[3,5]; (15 blocks of memory)
>
> Does it allocate a contiguous blocks of memory or not?
It does not.
At least not in the way I think you mean.
What it allocates is memory space for *references* to string objects, not
space for the objects themselves.
> What If I tried to go out of range but in a knowingly
> safe manner like the following in order to assign to
> the next array out of the 3 arrays:
>
> varray[0,5] = "string object"; // out of range overflow
> console.writeline(varray[0,1]);
>
> I tried it and I get an exception error, as I should, but,
> I also tried catching the exception to allow it to work
> but the problem is that the exception blocked my program
> before the assignment could occur; proving why I
> said it did not work. Am I wrong on this last assumption?
I don't even understand what you mean when you say that you "catch the
exception to allow it to work"?
If an exception is thrown because it isn't allowed, it won't be allowed
ever...
> In C, something like this particular program would work
> becuase C is not very strict when it comes to safety conforms.
Which is one of the problems of C.
In a C implementation that memory space could very well be occupied by
something else, which you'll destroy by exceeding the boundaries of the
allocated array.
// Bjorn A
.
- Prev by Date: Re: Urgent PrintPreview Error?
- Next by Date: Re: Urgent PrintPreview Error?
- Previous by thread: Urgent PrintPreview Error?
- Next by thread: Re: Technical two dimensional array question
- Index(es):
Relevant Pages
|