Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Overload This Method
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
How To Overload This Method
Divers
Thread ID:
01394418
Message ID:
01394418
Vues:
87
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?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform