Hey all, got one question about creation of functions. I have a
function that receives a sql string and a datagrid to populate.
void populate(DataGrid grid, string sql){
.....
}
Lets say I want to upgrade this function, so it can receive a
DataGrid OR a GridView, just like several C# functions can receive a
lot of different types (Convert.ToString() receives 36 I guess) how
could I do it ?? or maybe what should I search for ??
Thanks.
OZI - 13 Sep 2007 16:15 GMT
a Function should have a return value and you have void, method is the
name.
void populate(DataGrid grid, string sql){
private void populate(DataGrid grid, string sql){}
private void populate(GridView grdvw, string sql){}
just overload.
OZI
> Hey all, got one question about creation of functions. I have a
> function that receives a sql string and a datagrid to populate.
[quoted text clipped - 9 lines]
>
> Thanks.
Roland Dick - 13 Sep 2007 16:22 GMT
Hi,
Jl_G_0 schrieb:
> void populate(DataGrid grid, string sql){
> Lets say I want to upgrade this function, so it can receive a
> DataGrid OR a GridView, just like several C# functions can receive a
You can create a new function with the same name and other parameters, e.g.:
void populate(GridView grid, string sql)
The only thing to keep in mind is that the signature (= name of function
and number, order and type of parameters) must be unique.
Hope this helps,
Roland
Jl_G_0 - 13 Sep 2007 16:31 GMT
thx everybody. Yeah, its really not void, sorry... its INT populate(),
so it returns non-zero if it fails.
And I thought I could do this saving some lines of code, but looks
like I have to copy the same function over and over... well, it works
fine. thx again.