Answer the question
In order to leave comments, you need to log in
C# method returning generic type and type conversion?
Method:
class Cat { }
public List<T> method<T>()
{
return new List<Cat>(); // вместо new тут List<Любой тип> который приходит из EntityFramework
}
var c = method<Cat>();
Answer the question
In order to leave comments, you need to log in
The method declaration must have the same type that is returned from within:
public class Cat<T>{
public List<T> method()
{
return new List<T>();
}
}
public class Kitty
{
public void main()
{
Cat<String> kitty = new Cat<String>();
List<String> kittyMethods = kitty.method();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question