An array is always of a fixed length. If you want to use a longer array, you
must build a new array and copy all of the elements from the original array
into it, which is what Array.Resize does.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
I had the same problem once. Fixed it using the same solution.
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This is my first time posting so I hope i'm in the right place.
> I have a project which uses an xsd.exe generated .cs file containing
> the class definitions for each of my schema's XML elements.
> I am using this stucture in memory to maintain my data, but I have
> come across the problem that becuase it uses a fixed array [] and not
> an arraylist, it is a bit tricky to manage.
> I could modify the generated .cs file but the schema is large and if
> the schema changes in the future it would mean reworking it, this does
> not seem like the best solution.
> So at the moment I have a function like this to add an element to the
> array: It does not seem like the most elegant solution. I was
> wondering if anyone else had come across this problem. Note
> that ..ServiceTable is a property so i can't send it as a ref.
>
> private void NewService(object sender, EventArgs e)
> {
> ServiceType[] s = ESGMain.ESG.ServiceTable;
> Array.Resize(ref s, s.Length + 1);
> ESGMain.ESG.ServiceTable = s;
> s[s.Length - 1] = new ServiceType();
> s[s.Length - 1].serviceID = newServiceID;
> }
>
> thanks in advance
>