There is a generic function
Result<T> F<T>(int id) { .... }
void F2<T>(Result<T> r) { ... }
and there is a list of string (read from appsettings.json
).
List<(string, int)> s = new List<(string, int)> {
("int", 10),
("string", 21),
("DateTime", 31),
("int", 20)
... }
How to call F
with the items from the string list?
foreach (var (t, id) in s)
{
var result = F<???>(id); // need the type from t here
F2<???>(result);
}
Why I asked this:
The original code has a list of
F<int>(123);
F<string>(345);
F<int>(32);
F<Othertype>(32);
... many more ...
in the source code. And it needs to be updated/added from time to time. I'm trying to move it to the config file so I don't need to modify the code and recompile the code everytime.