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