From 6084e4d664098b066d6def972fe38da50b3400ba Mon Sep 17 00:00:00 2001 From: Dennis Neetix Date: Thu, 18 Feb 2021 09:32:45 +0100 Subject: [PATCH] ISSUE #32 - Add Named Arguments --- C# Coding Standards and Naming Conventions.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 66a39f1..6cada74 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -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)