declare type vs use var

时间:2015-11-12 10:56:37

标签: c# variables

Is there any benefit from declaring the type of var to be assigned

List<myType> example1 = methodToGetMyTypeList();

over using var for the same efect

var example2 = methodToGetMyTypeList();

besides the fact that if by some mistake i'm assigning the wrong type i'll get an error and it's best suited for readability and maintenance? In terms of performance.

0 个答案:

没有答案