JJ Jordan - MSFT
Hi Andrew,
The invalid cast error stems from the fact that ArrayList.ToArray() returns a standard Object array instead of any typed array. There is no way to simply cast object[] to eLecture[], even if all of the items in the array are eLecture's! If you could, then you could have some nasty things happening, e.g.:
object[] objArray = new object[] {"1", "2", "3"};
string[] strArray = (string[]) objArray; // Suppose this were legal.
// Note strArray == objArray (point to same array object)
objArray[0] = 1; // Then this is legal too
Debug.Assert(strArray[0] is string); // Should be true, but isn't!
You mentioned in your first message that the last line (enrollment[] manifest_final...) is working, but I'll bet it isn't, by the same rule. The proper way to create a typed array from an ArrayList is to do something like the following:
enrollment[] manifest_final = new enrollment[manifest.Count];
manifest.CopyTo(manifest_final);
Hope this helps,
JJ