Child pages
  • Use 'var' keyword when initializer explicitly declares type
Skip to end of metadata
Go to start of metadata

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:

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.:

  • No labels