Skip to content

Instantly share code, notes, and snippets.

@alistairjevans
Created May 15, 2020 12:42
Show Gist options
  • Save alistairjevans/4f77e82239312bc48bd18fad5b5c8420 to your computer and use it in GitHub Desktop.
Save alistairjevans/4f77e82239312bc48bd18fad5b5c8420 to your computer and use it in GitHub Desktop.
Default parameters on interfaces.
// Default arguments in interfaces.
// If you call the interface method, the passed value will be "interface".
// If you call the object method, the passed value will be "method".
// Should the compiler error?
public interface IPipelineBuilder
{
void AddStage(IPipelineStage stage, string mode = "interface");
}
public class PipelineBuilder : IPipelineBuilder
{
public void AddStage(IPipelineStage stage, string mode = "method")
{
// Do something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment