In VBA, you can use Application.Caller.Rows.Count to find out the expected size of an array forula, so you can return an array of the right size.
In c# you can also do this!
Check out the page Writing an Excel COM Addin first so you can get hold of the Application object.
Then:
Excel.Range range = (Excel.Range) application.get_Caller(System.Type.Missing);
int rows = range.Rows.Count;
int cols = range.Columns.Count;