I have a base class User .
I have 2 derived classes from a user called DerivedUser, OtherDerivedUser
I have the following code:
User user = newUser.CreateUserByType();
SendNewUser(user);
I don't want to execute an if or switch statement , and then do downcast for derived types.
I just want to make a single line call.
SendNewUser(user);
I want ** clean single-layer code *.
This method, according to its type, will dynamically “know” which method to call.
I have 2 functions called SendNewUser that are overloaded with a derived type.
Is there a way to call the correct function by downcasting to the right derived class (I don't want to explicitly throw)
private static void SendNewUser(DerivedUser user){
...
}
private static void SendNewUser(OtherDerivedUser user){
...
}