.net - ReSharper & Implicitly Typed Variables -
.net - ReSharper & Implicitly Typed Variables -
i using resharper help me spotting possible errors in code, and, although not error, keeps complaining should utilize var
keyword instead of explicitly typing variables on declaration. personally, think much more clear me , reading code if write
ilist<t> somevar = new list<t>();
instead of
var somevar = new list<t>();
knowing there's no performance differences between both ways, should ignore these hints or stick `var´ keyword? matter of taste or practice implicitly type variables?
i see @ to the lowest degree 2 reasons.
first, matter of dry principle: don't repeat yourself. if in future decide alter type of variable list<>
stack<>
or linkedlist<>
, var
you'd have alter in 1 place, otherwise you'd have alter in 2 places.
two, generic types declaration can quite long. dictionary<string, dictionary<int, list<myobject>>>
anyone? doesn't apply simple list<t>
, shouldn't have 2 code styles different object types.
.net resharper implicit-typing
Comments
Post a Comment