Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
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)
{
}
}
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)
{
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: