C
C#14mo ago
RonTheDon

❔ function overloading with Type as parameter.

Hello i have this function : public string remoteCall(string Namespace, string Class, string Function, params object[] p) real example : remoteCall("Cus", "Customer", "GetCustomerTransactions", 123, "2020-01-01", "2021-01-01") 123 being the id and a range of dates. i would like to be able to overload the remoteCall function in a way that it would suggest the id and the 2 dates instead of it being a params object[]. something like this: public string remoteCall(Cus.Customer.GetCustomerTransactions, int Id, string date1, string date2) so that when i type Cus.Customer.GetCustomerTransactions as the first param, visual studio automatically suggests Id, date1 and date2 as the possible params. is this even possible? ty
6 Replies
Angius
Angius14mo ago
Uh, why not just give it the Customer...?
RonTheDon
RonTheDonOP14mo ago
i dont have a customer object. this function in called in a windows forms solution to communicate with the server solution through some tcp client
Angius
Angius13mo ago
Well, then besides making those parameters int and DateOnly respectively, I don't think you can do much
ZacharyPatten
ZacharyPatten13mo ago
Can you do it? yes, but I would highly recommend you do not mix overloads with params object[]. you are just asking for future issues. also "remoteCall" seems like a very vague name for a method in the first place
RonTheDon
RonTheDonOP13mo ago
the only other alternative i can think of is something like remoteCall.Cus.Customer.GetCustomerTransations(int, string, string) instead of remoteCall being a function, it could be a class and the namespace of the functions on my server solution could be nested classes.
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server