I
I
i__egor2020-06-24 18:35:36
C++ / C#
i__egor, 2020-06-24 18:35:36

How to get and insert a type argument into a generic?

I want to insert T into a function with a generalization (for example, ToPlace(.....) ). In the function where I call ToPlace<>(), I do not pass the type. so I want to get it from the array
I'm trying like this:

Type t = mas[0]; //где массив типа Sysetm Type
ToPlace<t>(.....); //пишет: "t" является переменная, но используется как тип

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-06-27
@vabka

No way. Cast all objects to object and sort through reflection at runtime.
Along the way, you can add an overload for the ToPlace(..., Type type) method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question