Optional parameters - specify one out of several

c#

Solution

Since the first parameter is `count`, it is expecting an `int?` not a `bool`.

You can provide named parameters like it describes here.

DoStuff(isValid: true);

Problem

I have a method which accepts three optional parameters. ``` public int DoStuff(int? count = null, bool? isValid = null, string name = "default") { //Do Something } ``` My question is, if I call this method and pass a single method argument: ``` var isValid = true; DoStuff(isValid); ``` I get the the following error: Argument 1: cannot convert from 'bool' to 'int?' Is it possible to pass a single method argument, and specify which parameter I wish to specify?

Original source