I just started using Resharper. One of its features is that it suggests changes to the code based on, i suppose, good coding practices.
One of the changes it suggested is to change the variable type to var during assignment. I kept on changing and now the code has var everywhere. Somehow I get the feeling that “var” keyword makes the code a bit difficult to understand.
Is it a good coding practice to use “var” whereever possible or is it better to stick with the actual type. (except anonymous types where its required to use “var”)
Thanks.
The C# programming guide suggest using var when it enhances readability, for instance when the type is obvious, too complicated or not important at all.
There is no general rule. There are situations where the explicit type may enhance readability.
Examples: