From 83de68851995391bb03f86a07e484dd5559004ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Can=20Ta=C5=9F?= Date: Sat, 19 Dec 2020 21:12:49 +0300 Subject: [PATCH] Add new type definition suggestion Avoid var type when you use method for variable definition --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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