c# - Optional parameters - specify one out of several -
i have method accepts 3 optional parameters.
public int dostuff(int? count = null, bool? isvalid = null, string name = "default") { //do } my question is, if call method , pass single method argument:
var isvalid = true; dostuff(isvalid); i the following error:
argument 1: cannot convert 'bool' 'int?'
is possible pass single method argument, , specify parameter wish specify?
since first parameter count, expecting int? not bool.
you can provide named parameters describes here.
dostuff(isvalid: true);
Comments
Post a Comment