So, is there some sort of performance gain to be had from changing the List to a var
No but this is not the only valid reason for a refactoring. More importantly, it removes redundance and makes the code shorter without any loss in clarity.
I've always been taught that explicitly defining a variable, rather than using a dynamic, is more optimal.
You misunderstand what var
means. This is not in any way dynamic, since it produces the same output. It just means that the compiler figures the type for the variable out by itself. It's obviously capable of doing so, since this is the same mechanism used to test for type safety and correctness.
It also removes a completely useless code duplication. For simple types, this might not be much. But consider:
SomeNamespace.AndSomeVeryLongTypeName foo = new SomeNamespace.AndSomeVeryLongTypeName();
Clearly, in this case doubling the name is not just unnecessary but actually harmful.