Skip to content

Non-trailing named arguments C# 7.2code reduction

Allow named and unnamed arguments to be more freely mixed.

In prior versions of C# once a named argument was used all subsequent arguments had to be named.

This can be quite restrictive in some scenarios, such as when wanting to specify the name for boolean arguments for clarification but not wanting to name all subsequent more obvious arguments.

Code

C#
UpdateOrderStatus(orderId, shipped: True, trackingId);
C#
UpdateOrderStatus(orderId, shipped: True, tracking: trackingId);

Notes

  • Arguments after the named argument must honor the order of the method signature or be named.

More information