asp.net - Declare return Type of the Function when there are two possible returned types -


I have the following statement, I want to change it to a public shared function:

  If employees are employees then employee employees will return to the instances = GetEmployeeInstanceByUserId (userId) employee as employees of new employees Internships as new student students in the form of staff: GetStudentInstanceByUserId (userId) Student student withdrawal if  < / Pre> 

Public Shared Function GetWorkerIns Tance (Byval as IMployee boolean) ... (make sure not to write here) ...

There are two potential return types I'm not sure for the return type type What should be declared.

Any suggestions? Thank you.

It would be easiest if both employees and one parent (Either a base class or interface) students, you can use it as your return type.

You can not declare different return types at a function and you will not be able to create overrides that make different types of returns, because the method is not considered for return type in signature resolution. .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -