diff --git a/README.md b/README.md index 16c6930..28155cb 100644 --- a/README.md +++ b/README.md @@ -437,6 +437,28 @@ foreach (var location in locations) +
+ Avoid var type when you use method for variable definition + +The var type should only be used when defining a new object. When defining a variable with any method call, specifying the type of the variable will make it easier for software developers who read the code. In this way, you can know which type of value is returned without taking your mouse over the method you call. + +**Bad:** + +```csharp +var address = _customerService.GetCustomerAddress(); +``` + +**Good:** + +```csharp +CustomerAddress address = _customerService.GetCustomerAddress(); + +``` + +**[⬆ back to top](#table-of-contents)** + +
+
Avoid magic string