Answer the question
In order to leave comments, you need to log in
How to turn several methods that do the same job into one?
How can you refactor the code if it has grown a lot with repetitive methods? They do the same thing, but just return different types.
Making the method generic is not an option, because a generic type can only call the standard constructor, which is not present in valid types.
Answer the question
In order to leave comments, you need to log in
Making the method generic is not an optionthe very option
a generic type can only call the standard constructormethods do not have constructors . they visit classes . It is clear that your problem is in a misunderstanding, but it is not clear what exactly. if you were to give an example of a header ( upd or rather the whole method) of a generic method, and point out where it fails to meet the needs - this could be discussed. maybe even immediately show the solution
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question