The ability to define default values for method arguments can make a method easier to use. Default argument values allow callers to specify as many or as few arguments as they want while getting the same functionality and minimizing boilerplate, wrapper code. 


But all method arguments with default values should be declared after the method arguments without default values. Otherwise, it makes it cumbersome for callers to take advantage of defaults; they must either use named arguments or re-specify the defaulted values in order to "get to" the non-default arguments.

== Noncompliant Code Example

----
class MyClass
{
  public void DoStuff([Optional]int i, int j)  // Noncompliant
  {
    // ...
  }
}
----

== Compliant Solution

----
class MyClass
{
  public void DoStuff(int j, [Optional]int i)
  {
    // ...
  }
}
----

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
