The answers above are correct, but don't actually explain this specific exception.
Currently the Type of the values returned by SqlDataReader.GetValues() at compile-time and runtime is unknown, so by default it is the lowest common denominator, Object. The actual type depends on (a) the type of the column in the table in the database; (b) the type to which SqlDataReader translates the column's data type. Let's assume the sql column is SqlInt32 and SqlDataReader is converting it to Int32 (aka int).
Once your loop is done you are left with rowList that looks something like this (let's say there are 4 rows):
ArrayList
{
object[] { 1, 2 },
object[] { 3, 4 },
object[] { 5, 6 },
object[] { 7, 8 },
}
Although we know that those values are ints, if you were to check their types they are actually boxed ints. (see
Boxing)
Now let's look at your code:
Point[] y = (Point)rowList.ToArray(typeof(Point[]));
This will be run first:
rowList.ToArray(typeof(Point[]))
So you're asking it to take each element of the ArrayList and convert it to Point[], then return an array, which will be Point[][]. That poses a few problems. There is no implicit or explicit conversion from object[] to Point[]. Regardless, I can't think of a way to convert { 1, 2 } to an array of points, can you? I think you meant:
rowList.ToArray(typeof(Point));
but even that won't work because there is no conversion from object[] to Point.
Even if that were successful and returned Point[], you are then explicitly casting the result to Point and then assigning it to Point[] again.
Here's how I'd write it:
var HappyFunPoints = new List<point>();
rdr = inkcmd.ExecuteReader();
while (rdr.Read())
{
var x = rdr.GetInt32(0);
var y = rdr.GetInt32(1);
var p = new Point(x, y);
HappyFunPoints.Add(p);
}
foreach(var p in HappyFunPoints)