Return multiple values from a function

RK62

Active member
Joined
Dec 29, 2010
Messages
33
Programming Experience
3-5
Is it possible to make a function that returns both a datatable AND a list(of custom class) at the same?
In my GUI layer, the main form (the application is MDI) calls this function and it has to fill the datagrid on one of its child forms and it also has to fill lot of other child forms with various information that is calculated from my custom class properties.

Both the datatable and the class properties are created from the same external database and that's why I don't want to have two separate functions.
 
A function has one return value. One and one only. That one value can be anything at all though. It might even be a form that contains multiple controls. One object can contain as much data as you want. One object can contain both a DataTable and a List. You just have to define a suitable type and then create an instance.
 
While it is possible to use out parameters (defined ByRef) it is usually considered best practise to do as jmcilhinney explained, define a type to hold all your return data and use that as function return type.
 
Back
Top