Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Overload This Method
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
How To Overload This Method
Miscellaneous
Thread ID:
01394418
Message ID:
01394418
Views:
85
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
Next
Reply
Map
View

Click here to load this message in the networking platform