>I have a method call GetClients. It take either a CompanyKey, a ClientKey or both. Both of them are int's.
>
>
> public static SqlDataReader GetClients()
> {
> return GetClients(-1, -1);
> }
> public static SqlDataReader GetClients(int iClientKey)
> {
> return GetClients(-1, iClientKey);
> }
> public static SqlDataReader GetClients(int iCompanyKey)
> {
> return GetClients(iCompanyKey, -1);
> }
> public static SqlDataReader GetClients(int iCompanyKey, int iClientKey)
> {
> // The code is here
> }
>
>
>I get a compile error on the third overload "csAppDataAccess' already defines a member called 'GetClients' with the same parameter types"
>
>Even though the paramaters are both the same type, they represent different data. I guess I could make one a double and the other int, but I'm wondering if there's a better way?
You're right, in order to overload a method the parameter types have to be different. How about two methods, GetClientsByClient() and GetClientsByCompany()?