Except for non human readable code is there another reason not to use var for every variable in functions? I mean is it performance hit not to use int, SqlCommand, string but use var instead?
It's about implicit and explicit typing
. C#.NET is a typed language, meaning that you define what type of data is stored in memory. If you don't define that, you make some operations less safe, so you want to type explicitly as much as possibly. However in some cases the type is really obvious from your code, so you can just leave it up to the compiler to figure out what type the variable should be, which is implicit typing
.
A problem with not having types is that in memory, which is essentially a bunch of 1's and 0's this data could mean anything, so if you originally put in an integer at location 000001 and then later try to read it as Cat (just imagine that being some type), then nothing of what you just read out from memory will make much sense. So that is the reason that a type system was invented, to tell you what data you are storing where and to make sure that you read data back in a way which can be understood again by humans, as for a machine it doesn't really matter at the end of the day what the data is.