P
P
Prizm2020-04-18 10:56:16
C++ / C#
Prizm, 2020-04-18 10:56:16

How to create an object in c# depending on the type?

Let me have some object Type t. Also, there are a number of classes with a common interface (let the classes be called A, B, and the interface - AB). They have constructors that take the same parameters as an argument. How can you create an object of the desired type depending on t? I don’t want to use switch / if and the like, because there can be at least 50 such classes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-04-18
@PrizmMARgh

https://docs.microsoft.com/ru-ru/dotnet/api/system...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question