Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Redirect
locationhttp://www.jetbrains.com/resharperplatform/help?Keyword=Using_var_Keyword_in_Declarations

The var keyword is fairly controversial in terms of usage and any advice to use var in code is, by definition, opinionated. One of the potential uses of var is in initializations similar to the following:

Code Block
none
none

Dictionary<int,string> keys = new Dictionary<int,string>();

Since the type is declared on both left and right-hand sides of the initialization statement, ReSharper offers to remove the type on the left-hand side and replace it with var, i.e.:

Code Block
none
none

var keys = new Dictionary<int,string>();