Quote:
Originally Posted by office politics i'm getting index out of bounds when trying to assign ok the the a array. Code: static void Main(string[] args)
{
string[] a = new string[0];
Console.WriteLine(a.GetUpperBound(0) + 1);
Array.Resize(ref a, a.GetUpperBound(0) + 1);
a[0] = "ok";
Console.WriteLine(a[0]);
}
|
Hi friend
This is my first post and feel that i am useful at C#.NET...
How familar are you with C#?
Index out of bounds means your trying to access a position within the array that is unavailable or not assigned anything..
The size of an array is ALWAYS "length - 1", as indexing starts at 0 within array, so what you are doing with the + 1 is incorrect. Additionally your array doesnt seem to have a size as you have assigned it 0, although as i said the indexing starts at 0, you still must assign a vaule <=1.
Let me know how you get on
All The Best
NeoMagic33