Parameters
On this page
✅ DO use camelCasing in parameter names.
✅ DO use descriptive parameter names.
✅ For functions that have several configuration options, consider defining a single class or struct to hold all the options and pass an instance of that. This approach has several advantages. Options are referenced by name at the call site, which clarifies their meaning. It also reduces function argument count, which makes function calls easier to read and write. As an added benefit, call sites don’t need to be changed when another option is added.
Consider the following example:
// Avoid DecimalNumber product = CalculateProduct(values, 7, false, null); // Good var options = new ProductOptions { PrecisionDecimals = 7, CacheUsage.DontUseCache }; DecimalNumber product = CalculateProduct(values, options, completionDelegate: null);
❌ DO NOT create names of parameters in methods (or constructors) which differ only by the register:
// Avoid private void Save(string name, string Name) { // ... }
Why: consistent with the Microsoft’s .NET Framework and easy to read, and also excludes possibility of occurrence of conflict situations.