As gdoron says, there's no right or wrong answer, but in the interests of opinion, I'll give mine.
I generally always explicitly use the type, rather than var
because I find it is easier to understand what type something is. E.g, for someone else reading your code, it's clear what the type is.
In your example, it's hardly noticeable and a casual reader can easily see what is a string and what is an int. However, consider:
var f = SomeFunction();
To the eyes, it's not clear what the type of f
is immediately.
That said, var
can be useful when doing something like:
var userMap_ = new Dictionary<string, User>();
as that surely saves some typing and it's clear what the type is.