I
I
Ivan Baturin2020-05-21 20:27:26
C++ / C#
Ivan Baturin, 2020-05-21 20:27:26

Is it possible to specify a generic type as the type of a method?

There is a method

public static List<T>(DbContext cntx, string tableName){...}


Can I somehow specify the generic type List[T] in this method. Because it is not known what type of variable the method will return in the future.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-05-22
@MrLumus

Yes. But then sort it out yourself, where will you get this T from.

public static T List<T>(DbContext cntx, string tableName)

In general, it looks like you want to file your own ORM - it's better not to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question