ISSUE #32 - Add Named Arguments

This commit is contained in:
Dennis Neetix
2021-02-18 09:32:45 +01:00
parent 22b067011e
commit 6084e4d664
+19 -1
View File
@@ -413,7 +413,7 @@ public class BarcodeReadException : System.Exception
***Why: consistent with the Microsoft's .NET Framework and easy to read.***
#### 26. Do use prefix Any, Is, Have or similar keywords for boolean identifier :
#### 26. Do use prefix Any, Is, Have or similar keywords for boolean identifier:
```csharp
// Correct
@@ -424,6 +424,24 @@ public static bool IsNullOrEmpty(string value) {
***Why: consistent with the Microsoft's .NET Framework and easy to read.***
#### 27. Use Named Arguments in method calls:
When calling a method, arguments are passed with the parameter name followed by a colon and a value.
```csharp
// Method
public void DoSomething(string foo, int bar)
{
...
}
// Avoid
DoSomething("someString", 1);
// Correct
DoSomething(foo: "someString", bar: 1);
```
***Why: consistent with the Microsoft's .NET Framework and easy to read. In Named Arguments, we do not need to pass the parameters in order as defined on method definition, so we can pass the arguments in any order on method calling.***
## Offical Reference
1. [MSDN General Naming Conventions](http://msdn.microsoft.com/en-us/library/ms229045(v=vs.110).aspx)