C# Error
CS1737 – Optional parameters must appear after all required parameters
Reason for the Error & Solution
Optional parameters must appear after all required parameters
The compiler does not support optional parameters being declared before required parameters. All optional parameters must be after all required parameters.
Example
The following sample generates CS1737:
// CS1737.cs (7,45)
class C
{
static void F(object? x)
{
G(y: x);
}
static void G(object? x = null, object y)
{
}
}
To correct this error
The signature for this method may be changed without effecting existing code that calls the method because a value for the optional parameter has not been used. For example:
// CS1737.cs (7,45)
class C
{
static void F(object? x)
{
G(y: x);
}
static void G(object y, object? x = null)
{
}
}