mirror of
https://github.com/Stone-Red-Code/naming-convention.git
synced 2026-09-04 09:06:19 +02:00
ISSUE #32 - Add Named Arguments
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user