5
I was reviewing some methods of an ASP.NET MVC project and found some cases where it is used only .ToList()
and others in which it is used .ToList<type>()
(where type is an object type used in context).
Imagine that only with the .ToList()
you would already have a list with the type you need, why would you use a ToList()
typical?
Take the example:
Note: The property PessoaId
is of the whole type.
var pessoasIds = db.Pessoa.Select(p => p.PessoaId).ToList();
Same typical example:
var pessoasIds = db.Pessoa.Select(p => p.PessoaId).ToList<int>();
Is there any difference in performance for example?
Doubt also extends to other methods, such as .ToArray()
.