P
P
phoboson2018-11-20 16:58:36
C++ / C#
phoboson, 2018-11-20 16:58:36

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

1 answer(s)
#
#, 2018-11-20
@mindtester

Making the method generic is not an option
the very option
a generic type can only call the standard constructor
methods 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 question

Ask a Question

731 491 924 answers to any question